Adding new rows to excel sheet

Hello all,

I have been stuck on this for an embarrassing amount of time. I am getting categories from outlook messages and building a data table to output to an excel sheet. Basically the every time I run the bot it should output a row like…

Date | Category Count
2/28/2024 | 8

And every time I use a write range or append activity in an application scope the data gets replaced. For example if I ran the bot again instead of showing

Date | Category Count
2/28/2024 | 8
2/28/2024 | 13

It will show

Date | Category Count
2/28/2024 | 13

Effectively erasing previous data.

Any help would be appreciated.

Hi @srobey888

Could you check if you are adding the data to the same datatable you are reading it and writing the datatable with all the new data?
also look possible duplicated variables

Regards

Can you show your code?

@srobey888 ,

We have two option:

  1. Use Append Range Activity
  2. If Above not working for you use this one.
    –>Prepare DataTable to write to excel with your categories from outlook messages data.
    –>Before writing new data to existing excel file data, read it to DataTable with Read Range activity.
    —>Use If Condition activity and check if DataTable have any Rows by this dt.Rows.Count > 0
    In If block use Activities - Merge Data Table (uipath.com) and merge to be written Datatable into existing data Datatable. Use Write Range to write the output datatable to excel.
    In Else block Use Write Range to write the DataTable to write to excel with your categories from outlook messages to excel.

That’s it.

Thanks,
Ashok :slight_smile:

This is what I am using. Basically sheet two outputs a row and I want to move that row to sheet 3 that has all the rows from every bot run. But the problem, lets say I write range gets 10 emails, those 10 emails should be aggregrated into one row, but in the append range it adds a row for each email so I end up with 10 new rows.

in the append range you are writing a different datatable that is not needed , Instead write the same datatable specified in writerange

Append Range: Exception from HRESULT: 0x800A03EC - I am getting this error now for the append range. I have troubleshooted everything, but still getting the error.

Hi @srobey888

Please try this

OldData:

image

NewData:

image

FinalData:(OldData)

image

Regards,

Hello, I have not been able to use the workbook activities because I get the Method not found “Void ClosedXML” error and could not figure out why

@srobey888

Can you please share your xaml file

Unfortunately I can’t because of the sensitive data, but I do have all my packages fully updated, so I know that is not the problem.

@srobey888

No problem. Atleast can you share the ss of workflow


@srobey888

Why are you using Write Range and Read Range? No need to use Write Range and Read Range you can directly use Append Range activity

image

The write range is to output the newest data from the email categories, then read that data and move it to the other sheet, if that makes sense. When I take out write range it still has the void closedxml error.

@srobey888

Can you please share the error

Read Range: Method not found: ‘Void ClosedXML.Excel.XLWorkbook…ctor(ClosedXML.Excel.XLEventTracking)’.

@srobey888

Try to update UiPath.Excel.Activities Package

Hi @srobey888

Welcome to UiPath community!

Instead of using “Append Range” you can simply use “Add Data row” Activity to add the current row in your existing data table variable.

  1. Use a Read range activity to read the existing/empty excel with headers.
  2. Start adding the current row in the for each loop with “Add Data row” if you have multiple rows at a time.
  3. Use a write range activity to write the added data.

It will help you adding the new rows below the existing row in the same excel. Cheers! :blush:

Thanks
Biswajeet

Do this all the time , should be simple as this , unless you doing something wrong here

image