llayla
March 13, 2023, 3:25am
1
Hello,
I’m currently creating an email with an HTML body table. The email has been successfully created, but the output table does not have a header, how do i set it, so that the header appears in the table. By the way, I created the HTML syntax through the “Create HTML Content” activity. i appreciate for any help. Thank you.
1 Like
Yoichi
(Yoichi)
March 13, 2023, 3:43am
2
Hi,
As a workaround, can you try as the following?
dr = dt.NewRow
dr.ItemArray = dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray
Then call dt.Rows.InsertAt(dr,0) using InvokeMethod activity
note: This assume all the column type are string or object.
Regards,
1 Like
llayla
March 13, 2023, 3:54am
3
@Yoichi it means we add a row containing the header name manually in the datatable that we want to print, isn’t it?
Yoichi
(Yoichi)
March 13, 2023, 3:56am
4
Hi,
Yes. And it requires the above assumption : column type is string or object.
Regards,
llayla
March 13, 2023, 4:06am
5
Ok, i get it. But what is the contents of the dr.ItemArray variable. I mean, does the variable dr.ItemArray automatically contain the header name when using this syntax. I do not exactly understand what this syntax means. Could u please give me a little bit explanation. Thank u so much
dr.ItemArray = dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray
You can refer to this How to pass datatable to html with headers
Basically you will need to output your datatable to string(csv), then read it back to datatable without useRowHeader.
3 Likes
Yoichi
(Yoichi)
March 13, 2023, 4:15am
7
Hi,
We can set items of the datarow using dr.ItemArray
And
dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray
is LINQ expression to create column name array. More specific,
dr.Columns returns ColumnCollection and Cast converts it to IEnumerable<DataColumn>
for able to handle by LINQ.
Select(Function(dc) dc.ColumnName).ToArray
returns ColumnName array from IEnumerable<DataColumn>
instance.
As a result, items of the datarow are set the column name string.
Regards,
llayla
March 13, 2023, 4:23am
8
@Yoichi thank you so much for the complete explanation. very helpful
1 Like
llayla
March 13, 2023, 4:23am
9
@yi.ying.lee , Wow, that’s a much faster way. Thanks so much
system
(system)
Closed
March 16, 2023, 4:24am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.