Can you answer the following questions
1.Do you have any rule to select the fields from excel?
2. Is there any rule for the word file also? Data in the 3rd row of word file do not follow the pattern of 2nd row in the file.
3. What is H, D in the start of the word file?
The Output can be easily done by using a Transpose Datatable Activity. The workflow uses an external package. You can download the highlighted package from the Manage Packages and use the workflow I have provided.
This is not an elegant solution but I would suggest that you read the Excel file into a datatable and loop through this datatable to remove any unnecessary rows and separate the data (this may have to use hard coded business rules such as "does column1 contain ID? If so, keep the row. If column1=end, then create a new variable after this row). Once you have sorted the data, you can then manipulate it into the text file that you require. My other suggestion would be to perhaps change the process if possible so that the input data is more structured, making your data easier to manage.