Append Range Not Writing Headers, Write Range Overwrites Existing Data – How to Fix..?

I have a data table that I want to write into an Excel file.
When I use Append Range (Workbook), all the data is added correctly, but the header row is not written.
When I use Write Range (Workbook), the header and the first row are written correctly, but all the next rows get overwritten instead of being appended.

Append Range does NOT support writing headers, so you are not getting headers.
It only appends data rows.

image

To append data with headers, first verify whether the sheet is empty.

If it’s empty, use Write Range with AddHeaders = True.
If it already has data, identify the last used row and write the new data starting from the next row.

This ensures the header is written only once, and all subsequent data is appended without overwriting.

1 Like

To append with headers, first check if the sheet is empty. If empty, use Write Range with AddHeaders enabled. If not empty, find the last used row and use Write Range starting from the next row. This way the header is written only once and the remaining rows are appended without overwriting.

@S_Yuvaraj

That’s the expected behavior. How you want to write it?

hii @S_Yuvaraj

If activity to check if your file already exists Use Write Range with Add Headers enabled for the very first write to create the file then use Append Range for all following writes to add data without overwriting

Write Range Workbook:

Use this activity when you need to create a new Excel file or overwrite the existing data in a file. The data will be written starting from the specified cell (e.g., “A1”). and also we can pass the custom range from where to start and end.

You can review the properties of the Write Range Workbook activity below.

Append Range Workbook:

Use this activity when you already have an existing Excel file, and you want to add new data at the end of the existing rows without overwriting anything. The starting point is automatically the next empty row. and also we can pass the custom range here.

You can review the properties of the Append Range Workbook activity below.

The key differences between Write Range Workbook and Append Range Workbook are outlined below.

This is how they’re supposed to work. Write Range means just that, write to Excel - it isn’t appending. Append Range means just that, add rows - which means the headers should already be there.

What you should do is Read Range the first row, and if there are headers then you use Append Range, if there are not headers (ie it’s an empty Excel) then use Write Range.

@S_Yuvaraj

ideally thats the expected behaviour

but if you want headers, when creating the datatable or reading the data add the data without headers checkbox or add headers as first row in datatable so that in append range it would add headers as well

also when you say in write range only first row is correct and all other are replaced…then that might mean data is already present then even first row should be overwritten unless firstrow is same for all

cheers

I’m working on the BotsDNA website – first project: Customer Locator.
In this project, I’m using REFramework. I added data to the queue, then retrieved it and wrote it to an Excel sheet.

If I use Write Range, it overwrites the existing data and headers.
If I use Append Range, it correctly adds the data but doesn’t include headers.

Now, I want to add the headers once at the beginning, and then append all the data correctly to the sheet.

Hi @S_Yuvaraj ,
The correct approach is to control headers separately. Before processing, check if the Excel sheet is empty or does not exist. If it is empty, use Write Range once with AddHeaders enabled to write only the headers. After that, during processing, always use Append Range to add data rows. This way headers are written only once and data keeps appending correctly without overwriting.

Thank You So Much, if i have a issues i will reach you