Append Data in Excel with One line blank in Previous Data and Current Data

Cell A1 cell B1 Cell C1
Cell A2 cell B2 Cell C2=Previous Data
(Blank Row)
Cell A4 Cell B4 Cell C4=New Append Data…
Note:- Without Using Excel Scope Application…

Assuming the new Data to paste you have in dt_new.

Instead of Using Append Range - use a Write Range Here .

Steps :

  1. Read the existing excel in a DataTable Say dtExcel.
    2.Take an Integer Variable intCount = dtExcel.Rows.Count : This will give you the Number of rows avaiable in excel e.g : 15.
  2. Now in the Write Range specify cell as “A”+(intCount+2).tostring : This will give you A17 … Assuming the Data has to be written from the Cell A.


Mukesh

2 Likes

Thank you… @mukeshkala I tried this method before this but Rang writes from A4

What is the existing Row count in excel - that count should match the Row count in dtExcel. - Please verify that - you can verify the same by using a writeline - dtExce.Rows.count.tostring

I think , this count is coming as 2 , thats why you are getting A4


Mukesh

@mukeshkala Thank You for help Done with the write range.

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