Append doesnt work properly(for me) with Write DataTable to Excel activity

Hello,

I am automating a simple task, using an excel and a web browser. excel has login infos and web browser has the data i need for each account. for every row i am logging in successfully, extracting data selecting extraction as “saved data” then using write datatable to excel activity with append selected using my previously saved data to write and an empty sheet as destination. everything till here works as intented but when i run the automation next day (i clear the destination by myself) writing destination doesnt start from A1 in fact it starts from the previous day’s last row and appends from there. I dont understand what i am missing or doing wrong. destination is always empty before i run it. but it keeps appending/starting from previous days row. I would appreciate your help thanks a lot

@aayc

Welcome to our UiPath community.

Any ways you want to write the data from starting row onwards right. In that case, use Write Range activity and pass range as “A1” instead of Append Range activity.

1 Like

@aayc Try this before writing data into an excel sheet read the sheet data into a data table (DT). Take if activity with the condition as DT.rows.count>0. If the count is greater than 0 use append activity or in else block use write range activity

ok thanks for the answer. i dont know why but i dont have Write Range activity, i am using uipath.excel.activities v2.11.4. so i couldnt try what you suggested. i am sharing an image from the automation process. i am really curious whats missing and causing the problem. on first run it writes from A1, on second run even tho sheet is empty it continues from the last row from first run. I am not trying to append data each run, i am trying to append data for each row that this extraction process repeats.

image

image
try toggle “SHOW CLASSIC”
AND “show compability”

THEN YOU CAN FIND WRITE RANGE ACTIVITY

regards
ahmad

dear ahmad,

i dont have that settings as well. i think i am using an outdated version. my license says its studioX 2020 10.2

image

Hello,
You can use either of the below solution:

Is there any specific template you are keeping for the Excel? If not what you can Do is Delete the Excel if Exists in the starting of the execution and Use Write DataTable to Excel activity. If excel is not there, it will create a New file.

If you are using a Template. Then keep a template in Folder (Template), before to execution every day, let you bot delete yesterdays excel file and use copy activity to Copy the Template from Template Folder to your Required Folder. Then use that excel to append the DataTable.

If you want to write from A1 cell then its better to use Write Range and put the range A1 in the property.

thanks for the advices. i am not using template but i think i found a workaround. now it first extracts to a designated sheet and by using write to datatable excel activity i take data from there and write it on the destination sheet then i clear the first sheet to make it ready for next extraction. with this way now the data i extracted for each time nicely appends as i wanted.
but i am still curious why i had to find a workaround and why it didnt work at the first place.

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