How do I write on excel file same cell

Hello Team,

How do I write on excel file . I have to update one single excel cell from datatable containing one number ex: 1.4505 . I use WHILE and write cell but its writing on entire column row by row, not same cell.

@Ciprian_const

Welcome to our UiPath community.

You mean want to write entire DataTable in single excel cell.

If yes then follow below steps.

  1. Use Output DataTable activity to convert DataTable into string.
  2. And then use Write Cell activity and pass above output string to it.

I would like to know how to pass a value to Write Cell via a variable?

@tyagis

Declare one variable if type string named varinput = “1.405”

And then use Write Cell activity inside Excel Application Scope activity and pass above value,Sheet name and cell range you want to write the value to it.

Eg. Range: “A3”

I have a value that I am reading (“A1”)out of the same excel sheet and I’m confused as to how to pass a value to Write Cell(“B1”) when reading a row and then Write that read value to a cell.
image

@tyagis

Are you reading value from single cell or multiple cells ?

If you want to read from single cell then use Read Cell activity and it will give output as String and then pass it to Write Cell activity to write into particular cell.

Using Read Range to read the “A2” Column and using For Each row in the DataTable. I guess I cannot Write Cell with this approach or perhaps not sure if I can.


Test Excel Read-Write.xaml (8.4 KB)
vendor_codes.xlsx (9.8 KB)

@tyagis

Welcome to forums

If you are using Datatable and want to write in a column of a row then use assign and write as below

DatatableVariable.Rows(RowNumber).Item(ColumnName) = Your Value

If you are using Excel application scope / Workbook activities then you can use Write Cell activity

Hope this may help you

Thanks

This helped and solved the issue. Thanks
Now, is there a way to write cell to the next non-blank cell when running the for each loop second time otherwise it keeps on overwriting?

@tyagis

Usually, it will overwrite, if you don’t want this to overwrite then do as below

In this case place a if condition and write as below

CurrentRow(ColumName).ToString <> “”

In then don’t place anything, in else you can place what value to write

Hope this may help you

Thanks