Datatable into excel

Hello,

I have data table as in picture:

image

I have a datatable as shown in the picture. I need to create excel with three excel sheets: car 1 gas, car2 gas, car 3 gas.
The tabs should have columns time + car X gas

For example:

Sheet(“car 1 gas”)
column 0 - time
column 1 - car 1 gas

Sheet(“car 2 gas”)
column 0 - time
column 1 - car 2 gas

How can i aquire this? datable is in format:
column 0 - time
column 1 - car 1 gas
column 2 - car 2 gas
column 3 - car 3 gas

Hey @Ababt
you can try this way:
BlankProcess86.zip (11.9 KB)

image

@Ababt

Sequence1.zip (2.0 KB)
I have done this process for only car 1gas

image

dtResult1=(From row1 In Dt.AsEnumerable()
 Select dtResult1.Rows.Add(row1(0),row1(1))).CopyToDataTable()

dtResult2=(From row1 In Dt.AsEnumerable()
 Select dtResult2.Rows.Add(row1(0),row1(2))).CopyToDataTable()

dtResult3=(From row1 In Dt.AsEnumerable()
 Select dtResult3.Rows.Add(row1(0),row1(3))).CopyToDataTable()

Please try this hope this will works

Hi @Ababt

Check out the below zip file:

BlankProcess26.zip (53.8 KB)

Hope it helps!!

1 Like

Hello @Ababt,

please do check if the code helps for your query.

DataTabletToExcel.xaml (14.1 KB)

1 Like

Assign Activity
TableList | DataType: List(Of DataTable) =

(From cix in Enumerable.Range(0, dtData.Columns.Count).Skip(1)
Let arrCN = new Int32(){0,cix}.Select(Function (cn) dtData.Columns(cn).ColumnName).toArray
Select t = dtData.DefaultView.ToTable(false, arrCN)).ToList

For each activity | item in TableList - TypeArgument: DataTable

  • write item (the looped DataTable) to Excel
    • use: item.Columns(1).ColumnName for the sheetname

Edited: Bug Fix - missed 0 in Enumerable Range

1 Like

Hi @Ababt -

Just use the filter data table activity 3 times and in the output column tab mentioned, click on keep and put your required column names.