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.
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.