Writing data to excel after extracting data from images

I am trying write data to an excel file after extracting the data form images in UiPath. But i am getting an error at write range activity. Below is the screenshot

image
Can anyone help me with this issue?

Can you please check the datatable variable which you are used in write range

Regards,
NaNi

@Seema_Jethe

Looks like the DataTable ‘exceldata’ is null. Can please check this on ‘Debug’ mode?

Thank you.

@THIRU_NANI I am using exceldata variable. below is the screenshot

Should i use some other variable?

Actually when your trying to extract the data it will create default variable as ExtractedDatatable. please can you check with that?

Regards,
NaNi

@Jobin_Joy I have checked in debug mode the exceldata variable is null. How can i resolve this issue? could u please help me with this issue?

In that case You need to extract the data again using data scraping

Regards,
NaNi

@Seema_Jethe

The data you are extracting from images should to supplied to DataTable (exceldata) row as column value.

Can you tell me columns/fields you are extracting from Image? so that I can help you with DataTable structure,

Thank you.

@THIRU_NANI but when i tried to print the data using log message activity I am getting all the values. Below is the screenshot

image

Hi

If it’s known that sometimes the DATATABLE variable is empty then use this IF activity before excel activity

The condition will be

exceldata.Rows.Count>0

If true it goes to THEN block where use a EXCEL activity to write it to a excel file

Or

If the datatable is expected to have a value in it
Then check with the activity with which it extracts data

Cheers @Seema_Jethe

@Jobin_Joy the fields which i am trying to extract include Account Number, IFSC code and PAN Number

@Seema_Jethe

Here is the example how you can build a DataTable and load data into the same.

Step 1: Build the data table with required columns (ex: CardNumber, CardName etc)
Step 2: Assign the value you are getting from image to respective columns

Refer the below inline screenshots for the above steps.

Note: If you have multiple rows to be add in the data table, implement loop and inside that loop perform step 2.
ExcelDT 1

Hope this will help you. Thank you.

@Jobin_Joy Can u please show the VB expression in the assign activity right after the build data table activity?

@Seema_Jethe

Here is the code,

ExcelDataDT.Rows(0)(0) - This is for First Column (CardNumber)
ExcelDataDT.Rows(0)(1) - This is for Second Column (CardName)

Note: If you are looping through any elements, you have to use the row index.

Ex:
ExcelDataDT.Rows(RowIndex)(0)
ExcelDataDT.Rows(RowIndex)(1)

where RowIndex is indicating the zero based index of the current element in the collection. (Highlighted in the screenshot)

Below is the inline screenshot for loop based scenario,

Hope this will solve your issue.

Thank you.

1 Like

@Jobin_Joy I tried your solution but it throws error as there is no row at 0 position. Below are the screenshots
image
image

image
image

@Seema_Jethe

I have no idea what’s the value of variable ‘outpu123’.

I have attached code and screenshots. Please make use of it.
The code is build on studio 2021.10.3


2

Code:
ExcelData.xaml (7.9 KB)

Hope this will help you. Thank you.

@Jobin_Joy The value for variable output123 is “HDFC12” but it is not getting assigned to
column in data table and throwing the same error as no row found at 0 position

@Seema_Jethe

Couple of things are wrong here,

1st - Your first column (Account Number) type is Int32 and you trying to assign a string value. This is will causing exception.

2nd- In the error message, its saying ‘There is no row at postion 2’. The Position 2 is indicating 3rd column which is not in the DataTable.

Kindly check and correct this. Thank you.

@Jobin_Joy thanks your solution helps

@Jobin_Joy If i use the data type as int 32 for account number then again it throws an exception as size too large or small hence i am using String data type