Append range workbook error/

I use Append range workbook but show eroor as below.

dt_result.DefaultView.ToTable(False,dt_result.Columns.Cast(Of DataColumn).Take(27).Select(Function(dc) dc.ColumnName).ToArray()).AsEnumerable.OrderBy(Function(r) CDate(r("Planned Start"))).CopyToDataTable

Please guide me for solve it.
Thank you.

Hi @Stef_99

Try the below one,

dt_result.DefaultView.ToTable(False,dt_result.Columns.Cast(Of DataColumn).Take(27).Select(Function(dc) dc.ColumnName).ToArray()).AsEnumerable.OrderBy(Function(r) (CDate(r("Planned Start"))).toString).CopyToDataTable

Hope it helps!!

@mkankatala same error.

Could you share your input data… @Stef_99

In the LINQ Query this part CDate(r(“Planned Start”)) only effecting the append range workbook.

Why you want to change the Values in Planned Start column from String to date. If you give me the more explanation about your query. Then we will try to sort your issue.

Hope you understand!!

@mkankatala

I want to copy column from input file column A-AA and sort Planned Start from old to new ----> append another file
Example input as attached.

input.xlsx (8.4 KB)

Based on your input the expression couldn’t matched what is your requirement… @Stef_99

dt_result.DefaultView.ToTable(False,dt_result.Columns.Cast(Of DataColumn).Take(27).Select(Function(dc) dc.ColumnName).ToArray()).AsEnumerable.OrderBy(Function(r) r("Planned Start")).CopyToDataTable

Do you want to change the format the values of Planned Start Column.

Could you be more specific…?

1 Like

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