Insert value in excel

i want to insert total(sum) below the last row
last row can be any

i want sum in 8th row
how to do insert value below the last rowCapture

Small change in the above expression
Yourdatatablename = Yourdatatablename.Asenumerable().Sum(Function(a) If(IsNumeric(a(“yourcolumnname”)),Convert.ToInt32(a(“yourcolumnname”).ToString.Trim),0).CopyToDatatable()

Cheers @Ananya1

1 Like

You can use write cell
Read Range will give you entire data say Datatable
Use Assign: Count= Datatable.Rows.count+1 (note: +1 is for adding headers if add headers in Read Range is checked)
Use write cell:cell Location i.e. Range=“B”+(count+1).ToString
value= “=SUM(B2:B”+count.ToString+“)” (Note for writing it in B column)

1 Like

copytodatable??

Hii @Ananya1

You can use this approach also
Take two variables sum, counter intilize sum to zero and counter to 1
Read excel file and store it in datatable.
Take for each row
In if statement put condition like

NOT String.IsNullOrEmpty(row(“Name”).ToString.Trim)
Read the cell value and add it sum variable
Once all the rows finished you will get last counter value
Use write cell activity in range use “Coulmnname”+counter.Tostring
and write the sum value into cell…

you can refer below XAML fileExcelsum.zip (171.5 KB)
:

Hi @amalmarella

Use dt=Dt.Asenumerable().Sum(row(“columnname”). ToString)

Thanks
Ashwin.S

1 Like