To clear data in an Excel sheet before writing a datatable in to it

hi,
Could someone help me on how to clear excel data in background without opening excel?

thank you.

2 Likes

Hi
we can do it simply with a delete activity and a normal excel application scope
–that is use DELETE activity and pass the filepath of the excel whose data you want to clear
this activity rather will directly delete that whole excel file itself
–now use a EXCEL APPLICATION SCOPE and pass the same filepath of excel so that new excel file of same name will be now created and then we can insert the datatable to it
this will work in background without opening the excel
Cheers @mc00476004

4 Likes

Thank you for the solution, As you said the delete activity will delete the excel sheet and the excel sheet that I am using has headers already prepared in advance, prior to running the workflow.

By using this approach the headers will not be created in the new excel sheet.

Is there any other alternative?

1 Like

Hi @mc00476004

Use clear datatable activity or using assign activity say newdt=Dt.clear or clone

Thanks
Ashwin.S

1 Like

Hi @mc00476004

use write range activities with the selected range Or try to use macros to delete the selected range.

cheers :smiley:

Happy learning :smiley:

1 Like

Hi, Can you please elaborate?

1 Like

Hi @mc00476004

You can set the range as empty and set the propertys of addheaders to true.

image

or you can use macro
image

cheers :smiley:

Happy learning :smiley:

2 Likes

But any how you will be having the headers for datatable right
So when entering the data if ADD HEADERS is enabled in WRITE RANGE activity then it would include the header as well

Cheers @mc00476004

1 Like

Hi @mc00476004

Just an idea, keep your excel with the headers as a template in some location whenever you want to fill data just take the copy of your excel and write it on it.

1 Like

You can invoke code(vbnet) to clear data

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