If we keep the build datatable in Process Transaction then the datatable will recreate for every transaction. If you had added any data to datatable in previous transaction then you loss the data. So we create the datatable in init state.
We can use write range activity in either final state or in no data transition. So that we can write the data to excel after all the transactions are completed.
If you want to write the workbook for every transaction, you can use append range activity. If you use write range activity then the data will be override.
You can use add datarow activity in process transaction to add the data to the main datatable(created in init state).
Later write the datatable to the excel using write range activity in final state.