Overwriting data in Excel

Hi Guys,

I amhaving one concern ,

If any exccel file alreqdy having data we are doing some linq on it and then again we have to write on same file, so what we need to do only write range would work? or some other way to do?

Example: If excel having 3 lines of record and after linq only one line have to write into same excel , what way it will work?


write range is like overwriting or can be shifted by the range parameter
other activites are available as well:

Your scenario maybe can well adressed by writing it to the same excel but on a new worksheet

so currently my only one row is getting overwritting but i dont want old data into it, how to do it.

let us understand your requirements

  • you have calculated someting and the result is datatable with 1 row
  • you want to write back to excel but currently there a 3 rows present in the worksheet
  • you are expecting after writing back the result only 1 row and the rest from the old data should be removed

Is our understanding right?

yes correct

a quick approach could by to delete existing worksheet
and let create newly ons data is written back

have look here for deleting a worksheet


template is there in excel so cant delete it.have to write in that sheet only.

maybe not the best approach but as the number of old existing rows is retrievable, give a try on filling up the the new datatable with empty rows and overwrite the old data with this