Hello All,
I have an Excel file in which I have marked few columns, I want that columns as output through LinqQuery.
Please help me with this.
New Microsoft Excel Worksheet.xlsx (34.9 KB)
Hi @ISBS_ROBOT ,
Could you elaborate a bit more on the output, Do you require the Datatable with only the Required columns or do you want the indicated column names as the output ?
I need the indicated data which I marked the headers in yellow as Output.
Assing activity
FilterCols | String Array =
new String(){"ColName1", "ColName2" ......}
Read range the excel into a datatable - dtData
Assign Acitvity
dtResult =
dtData.DefaultView.ToTable(false, FilterCols )
Hello,
It’s taking more time to execute. I need to trim the time and execute faster. Is it possible?
what was done in detail within your modelling?
Within the excel data out of 20-25 columns, I marked few columns and I want that columns and data as output. As the data will be heavy, Linq query would help in executing faster.
is not showing us the details of your implementation
No,
-
LINQ is not working against EXCEL
-
the statement
is not making transparent, where the speed is lost
You can try
- Approach by iterating over the column names and delete all unneded columns in a dynamic way
dynamic / manually prepare an empty datatable with configured reduced column set - dtResult
Assign Activity
dtResult =
(From d in YourOriginDataTableVar.AsEnumerable
let ra = FilterCols.Select(Function (x) d(x)).toArray
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
FilterCols as described above and with the same column order as configured dtResult