Build Data Table with headers

Hi, I am currently facing the challenge of creating a new table and adding headers to it, for this I found the following on the web

Now the part where the table is created is missing, I get an error message, how does it work with write range? BuildDataTable

You need to put the DataTable variable into the Write Range activity.

Also, I recommend using the Build DataTable activity to build a DataTable with headers!

Hi, I also thought that with Build Data Table the headings are set automatically, but only the table is created without headings.

@NHoe

Hope you have DataTable with Headers and data. Let’s say ‘InputDT’. Then try below expression to get only headers to new DataTable.

           newDT = InputDT.Clone

Initial situation is a completely new table that is filled with values from a webpage. The bot should create them including the headings

@NHoe

You need to pass DataTable to Write Range activity but you passed string to it. That’s why it’s showing that error.

Note: Output DataTable activity will convert DataTable to string.

@NHoe

In the Write Range Activity, instead of output_Vertriebshalt variable pass the data table variables which you want to write(DT_New_Vert… or DT_Vertrie…). The error should go with this.

Attached is my XAML with which I want to create a new table including headers, but it does not work. Main.xaml (6.9 KB)

I have the solution, although I would have liked a simple activity through Uipath.
Main.xaml (6.5 KB)

Thank you all

@NHoe,

Please use the WriteRange Activity(within Excel Scope Activity) under App Integration → Excel and not the one present under System-> File → WorkBook. Also, keep the Add Headers check box checked.

Sorry, I am unable to add attachments but let me know if you need any help :slight_smile:

Thanks Lipika,
(lipikapanda88@gmail.com)

@NHoe,

Step1 - Clone new datatable from existing one to just get the schema(Or Build Data table - this would require maintenance whenever schema changes, so cloning is easier.) New_DT = Old_DT.Clone

Step2 - Use WriteRange Activity(within Excel Scope Activity) under App Integration → Excel, with Add Headers checked. With this you will get just the headers written the the excel file. The System-> File → WorkBook-> Write Range activity doesnt writes only headersto excel, if the datatable is empty.

This is my working Solution

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