Convert system.collections.generic.list(of double[]) to Datatable with unknown number of columns

Hi All,

Someone have an idea on how to convert a system.collections.generic.list(of double) to a datatable. The number of items in de sub arrays are unknown, so i think this could be solved best with code. I’ve tried a for each but this is taking to much time because the list can be very big.

Any suggestions on what would work?


is the total number of items fixed?

Hi @dyuonn.bakker
Try this code in invoke code

list1.ForEach(Sub(r) dt1.Rows.Add(new Object() r))

where dt1 is the datatable where rows need to added

@ppr did this code work for the above query?

working with this sample list:

lets init an empty datatable and retrieve the length of longest array within the list

Lets add datacolumns of datatype double to the datatatable - as many as we do have items in the longest array
for the column name we do use the index output from for each as well

lets create the row itemarrays and add the datarows to the datatable:


find starter help here:
ListDoubleArray_VariantLength_ToDataTable.xaml (7.5 KB)

Thanks Peter it’s working, i’ve marked it as a solution.

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