Adding DataTable Row to Spreadsheet

I am currently working on a big datatable of Orders, I want to get the order # and then using a switch, put it into an excel spread sheet for a corresponding agent.

Psuedo code:
For each row in Orders Datatable
Switch statement for the order #
Matches and then will insert the current data table row into the corresponding agent’s excel sheet.

I am looking at “Append Range” but am unsure how to just add the current row from the “for each” loop instead of the entire Orders Datatable.

Hi @ckaminsky,

You’ll need to give a DataTable to the AppendRange activity. You could create an Array of DataRow with your row as unique element and apply to it copytoDataTable method.

I don’t know the impact in performance but could take another approach:

  • create a collection of items (datatable, dictionary, etc.) of your convenienc with each item containing the sheet name in one hand and in the other hand related values used in the switch.

  • iterate over this collection and for each element:

    • filter your big DataTable with related values
    • convert the result to a DataTable (not necessary if you use the DataTable filter activity)
    • use Append Range activity to related sheet and with this result