Is there a way to delete all the data from a sheet in excel without having excel installed on the machine bot will be running from?
I have a scenario where I need to read some data, manipulate, add, filter…then rewrite to the same sheet. Using only Write range will not work because if the beginning DT and the new DT are not the same size all the original data will not be overwritten…there will be leftovers.
So I need to read the original data then manipulate it using dt variables…then delete the original data from the sheet and rewrite the manipulated dt to the same excel sheet.
If you only want to retain the headers, then we could try emptying the rows without deleting them before writing it back to Excel using the Workbook Write Range Activity →
(From row In dt_sampleData.AsEnumerable()
Let rw = row.ItemArray.ToList()
Let empty = rw.ConvertAll(Function(c) c.ToString.Replace(c.ToString,"")).ToArray()
Select dt_clearData.Rows.Add(empty)).CopytoDataTable()
@kasey.betts Why don’t you write the updated data to a different file with same name
Read the data from actual file and store the file name in a variable. Move this file to a temporary folder
Do manipulations in the data table
Create different file in the same folder location where you got actual file, with same name as like the actual one and write the updated data using workbook write range
@kasey.betts , Assuming that we have the Data already available in Datatable, which Represents the Data in the Excel, we can use it’s Column Count and Row Count information to Clear the Contents using Write Cell Activity.
For Example :
Let the Datatable be DT
We get the Column Letter of the Excel by using the Column Count information as follows :