Build data table column names not working correctly

Hi folks, hope someone can help me out here.

Problem is as follows:
In some sequence I define a data table (DT1) using the build data table activity and then I use an assign activity to assign an extract of a different data table to DT1. So what I’m doing is this:

Build data table: DT1 (header1, header2, header3, etc…)

Assign: DT1 = DT2.AsEnumerable.Skip(x).Take(x).CopyToDataTable

The problem is that the headers I define in DT1 don’t work correctly. When I try to write DT1 to an Excel sheet, I get this instead of the column names I defined:

Does anyone have a clue why this is? Some of the columns in the extract are empty, but I compensate for that by allowing null values in the appropriate columns in DT1.

Hi @Westfield

Try checking the add headers property checked in Write range properties!

Regards

Already done, it’s on.

Hi
While using write range activity make sure ADD HEADERS property is enabled in it
Only then it will write the headers to excel
Else it will write only the column names like this
Column1, column2, …
And the data

And make sure you are referring to right data table with write range

Try running in debug mode to get more ideas on where it is missing

Cheers @Westfield

All of that I’ve already checked off my ‘list’, it’s none of those as far as I can see.

Hmm strange
Did we try upgrading excel package and checked on it

@Westfield

Ill look into that - you never know.

It wasn’t that either. Tried updating the Excel package - no dice.

Fine

Share the screenshot if possible t

Or atleast name of the activities used in sequence is fine either

@Westfield

I figured out what the problem was - I figured you’d want to know.

The problem is that for apparently technical reasons you quite simply cannot write one data tabel to another pre-defined data table. This is true at least for cases where you use read range or the .take() method.

For instance (the cases I tested) you cannot:

  1. Define a data table with headers using build data table
  2. Use read range (from excel, fx) to dump the range read into the data table you defined in step 1
  3. Write range DT1 to an Excel sheet or output data table

Neither can you:

  1. Define a data table with headers using build data table
  2. Assign another data table to the one you defined in step 1 with an assign act like fx [assign(DT1) = (DT2.AsEnumerable.Take(x).CopyToDataTable)]
  3. Write range DT1 to an Excel sheet or output data table

I tested this both with the operation data I’m working with and with a fresh Excel sheet with made up content. No matter what you do, as far as I can tell, UiP ignores the pre-defined data table and writes the data without the headers you define in DT1 - instead you get headers like in my screen dump above: column1, column2, column3, etc…

1 Like

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