Headings from predefined table

Hi all, I have a table that I read in via read range and whose headings I need for a new data table. The problem is that the original table comes from a report whose columns change from time to time. How can I transfer the headings to a new data table without having to manually adjust the build data table each time?

Bild 1
Bild2

Hey @NHoe,

You can use the Clone to get the structure of the table that you are reading.

NewDT = InputDT.Clone

Have a look on this thread, this will help you out.

Thanks,
Sanjit

Hi @Sanjit_Pal , If I clone the datatable I get the complete content, don’t I? but I only need the headings.

@NHoe, by cloning you will get the headers only not the content.

columnnamesdt
@NHoe use this one to get columns headers

and how do I get the headings output?

@NHoe I am not getting your point. what you want?

eg as string array:

arrColNames = yourDT.Columns.Cast(of DataColumns).Select(Function (x) x.ColumnName).toArray

strFlatString = String.Join(“,”, arrColNames)

This works almost the way I would like it to. How do I get this value into the heading of the new DataTable?

we are not sure if we get your questions as above the datatable.Clone method was mentioned

grafik

I have created a file here. The aim is to get the headings from the DT_Input in the DT_Clone.

Main.xaml (17.7 KB)

Hi,

follow issue i understand.

He has a Source File (ReadRange) where the Header is changed after the Process is developed.
He want a new Datatable what only use the exisiting headers, without this new Header Column.

The new Column ‘Date’ should be ignored, and only the first 2 column should be used.

Example:
ReadRange old: ID, OrderNumber

ReadRange new: ID, OrderNumber, Date

WriteRange new: ID, OrdnerNumber

I try a example, and found out dtInput.Clone (only Headers) – with the new Column, and the dtInput.Copy create a copy of the Source File, with the new Headers.

Maybe a solution will be, create a Excel Template with the Header (ID, OrderNumber) and somehow ^^ the new Datatable have only the Column ID, OrderNumber with the row Data.

or Merge Data Table https://docs.uipath.com/activities/docs/merge-data-table

@NHoe

Merge Data Table with a Excel Template

Merge Data Table.zip (67,8 KB)

Create a Excel Template with the Header you need (Template.xlsx) and with MergeDatatable and MissingSchemaAction ignore you get only this column from the Template with the Data from input.xlsx