Excel Append Range from data table, include headers if it does not exist

Hi, how do I use the Excel Append Range activity and include column headers if it does not exist? I am creating the Excel file from a data table with named columns

I don’t see an option to include headers here

HI @DEATHFISH

How about a solution like this…

  1. Take a count of the rows in the excel you are planning to write data using a read range.
  2. Use a IF condition and check whether the count is equal to zero.
    Dt_ExcelRead.Rows.Count = 0
  3. In the THEN segment of the IF condition, use a Write Range activity. We use it here because the excel currently does not have any data. This way, you can include the header as well.

In case the above condition returns false, that means the excel has more than zero records (basically it has records), then under Then segment of the IF condition, you can use the Append Range to add the new data. In this logic, you will not want to worry about the header because it will be handed by the write range activity…

Hope it helps!!!

2 Likes

Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.