Cannot infer an element type, add data row

Hello team. I’m facing this error “Cannot infer an element type because more than one type is possible.” Anyone know how to handle it?

In my workflow I download some data from SAP and add to an Excel file, create a pivot table and so on… But before paste into the Excel, I want to convert some of the data, for example in that column I want to convert to double.
I have a for each row in data table to do that,
My workflow:
For each row in Dt_main:
Add data row:
arrayrow:
all the string columns and converted columns
datatable:
dt_toExcel

In dt_toExcel, I have specified the data types as string and double (where I need to convert)

Hi @Scepanik_Mateus_uie11118

Try this below syntax

New Object() { row.Item(0).ToString,row.Item(1).ToString, row.Item(2).ToString,row.Item(3).ToString,row.Item(4).ToString,row.Item(5).ToString, row.Item(6).ToString, row.Item(7).ToString,row.Item(8).ToString,row.Item(9).ToString,row.Item(10).ToString, row.Item(11).ToString, row.Item(12).ToString, row.Item(13).ToString,row.Item(14).ToString, row.Item(15).ToString,row.Item(16).ToString, row.Item(17).ToString, row.Item(18).ToString, row.Item(19).ToString, row.Item(20).ToString, row.Item(21).ToString,row.Item(22).ToString,row.Item(23).ToString, 2 3 row.Item(24).ToString, row.Item(25).ToString,row.Item(26).ToString,row.Item(27).ToString,row.Item(28).ToString, Convert.ToDouble(row.Item(29).ToString), row.Item(30).ToString, row.Item(1).ToString}

Regards

@Scepanik_Mateus_uie11118,

You are getting this error because your array is of type Object.

Why not change the datatypes once you paste the data into Excel using Format Cells activity.

Thanks,
Ashok :slight_smile:

  • Use Object(){…}
  • Split the Array to some part Arrays, as IT will exceed max Arguments for Array assignmet
  • Concat Part Arrays to needed rowarray