S109_Facing the Exception While Adding the Add Data Row Act after extracting the Data from Invoice using Regex

Hi,

I am Facing an Exception While Adding the Add Data Row Activity after extracting the Data from the Invoice such as Invoice Number, Invoice Date, and Total Amount using Regex.

Problem: Unable to add the retrieved data from the Invoice to Excel.

In Array of Row, I have used this:
{OpInvoiceNum(0).value,OpInvoiceDate(0).value,OpTotalAmount(0).value}

Exception Type: Add Data Row: Unable to cast object of type ‘System.Text.RegularExpressions.MatchCollection’ to type ‘System.IConvertible’.Couldn’t store <System.Text.RegularExpressions.MatchCollection> in InvoiceNumber Column. Expected type is Int32.

Please Clarify and do needful.

Note: Related Screenshots for each step are attached.

Thanks in Advance,
Harsha.


Hi @Harsha_S1 ,

Could you show us the Columns created in Build Datatable activity ?

I have attached.

@Harsha_S1 ,

The Columns are of Type Int32, you would have to use CInt(OpInvoiceNum(0).value), when adding it to the Add Data Row Activity. Similarly for the other values as well.

Or you could change the Column Type to Object. It should accept the values in the Add Data Row Activity as it is.

Correction : Change the values in Array Row Property to the below :

{OpInvoiceNum(0).Value,OpInvoiceDate(0).Value}

OpInvoiceNum or OpInvoiceDate mostly are of type MatchCollection. We would need to access it’s Individual values, hence indexing is required.

Finally, I got the output by changing it to an object In Build Data Table. But In Excel, I am unable to get the proper format.
image
Please suggest.

@Harsha_S1 ,

Could you show us once more the Add Data Row Activity and the value in Array Row Property used?

Also, If you could provide us with the Regex Expressions used, we could also confirm on the outputs.

Hi,

Finally, I got the output. Thanks @supermanPunch

Regards,
Harsha.
image

1 Like

change the Column Type to Object.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.