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?

Thanks!

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?

@dyuonn.bakker
working with this sample list:
grafik

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

Lets add datacolumns of datatype double to the datatatable - as many as we do have items in the longest array
grafik
grafik
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:
grafik

Result:
grafik

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.