[i-adj] + ことに [na-adj] + な + ことに [verb た-form] + ことに
ことに opens a sentence with the speaker's feeling about what comes next: "to my surprise", "unfortunately", "happily". It follows an い-adjective, a な-adjective with な, or the た-form of a verb of feeling, and the fact that caused the feeling follows the comma.
The feeling is the speaker's own, about something that has happened or is a fact. The second half reports; it does not ask, invite or decide: ×嬉しいことに、一緒に行きましょう.
The verb takes the た-form: おどろいたことに驚いたことに, not ×驚くことに. Other words that take ことに this way include さいわい幸いなことに, ふしぎ不思議なことに, おもしろい面白いことに and ありがたいことに.
ことに belongs to writing, speeches and careful storytelling. In conversation, the feeling usually comes as a separate remark, or with an adverb such as ざんねん残念ながら.