Insert data in excel not working properly

I am using add data row and write range activity.
In my excel sheet 100 records inserted.Now I want to add data when I executing application it replace 100 records with new one.
I want records inserted after 101 record.

Hi @Aditya10989

Try to use Append Range Activity instead of Write Range

Regards,
Kommi Jeevan

2 Likes

hi @Aditya10989,

Apart from Append Range - We can Get the Dynamic cell in the Excel with steps below.

Lets say You have a Data till 100 Rows ans we want to Paste the data from A101

  1. We Read Range the sheet in excel and get the DataTable.
  2. We Count the No. of Rows in DT and store it in Integer variable say intCount- by using DT.Rows.Count - This will give you 100.
    3.Take a Sting variable Say Range and assign : A+intCount.toString.
  3. Use range from Step 3 for pasting the New Data.


Mukesh

3 Likes

this is not work for me

it remove my header while using write range

Please Check AddHeader Check Box in the Write Range Property - to Preserve Headers.

1 Like

As mention in attachment this not able to create header

I think the DataTable is Null,
Can you try Inserting one sample Row of Data and then Write Range with Preserve Header Checked.

yes I don’t want data.Because data inserted dynamic it create inside for each and I am creating header outside for each

If you want only One row of data , In the Build DataTable I can insert one Row with the Data Required (Header and Data can be Same) and then in Write range - I can write DataTable Without Header

image


Mukesh

1 Like

this is not work for me multiple condition.Can you tell me there any which can check in excel file sheet exist or not

Make use of Path exists and Pass the Excel Sheet Path. The Boolean variable IsExist - tells File Exist or Not .

not excel file sheet name

In your excel application scope you can use the “Get workbook sheets” activity. Save the output to a list<string> variable I’ll call xlSheets. Then in your if statement it should be if xlSheets.contains(“YourSheetName”)

Reference :

Sorry I have done huge code just because of I need to show demo in meeting meeting is over.Now can you explain me without data how we can add header…?

So if your datatable is empty and you attempt to write it in a excel… It will not write the data and datatable is blank and is having only header

Below I have suggested an alternative for this…

but the think is I am executing same excel file multiple time then it create multiple rows.
because I am processing huge data almost 20 k records.So I run this for 2 hour then stop so on.it create multiple header in between records.

So the main purpose of having header is to differentiate the data of various Runs ?

Plese correct.

means I am executing file multiple time because this is time taking process lets suppose first run its work fine I executed 1000 records now next execution after 1000 records it re create header in between data.
One think also work for me while executing second time it check header already exist or not if exist it skip build data table second or third time execution…?

  1. we can create 2 DataTable - one with only Header - dtHeader
  2. other with Header and one Row of Data (Same as Header) as shown in above threads -dtHeaderRow

3.Then we use an - IF Statement here and Checking the Datatable row count.

  1. If DT.rows.Count < 1 - That means DT is empty - we write range the dtHeaderRow
    else
    we wrrte Range the dtHeader
1 Like