Example table:
For example my columns list is List(Of String)({“a”,“b”}) i.e. i want to only show columns “a” and “b”
Steps to filter datatable by column names thats in a list:::
- read datatable from excel e.g. to variable called dt
- assign
New DataView(dt)
to a dataview variable - assign
dataView.ToTable(false,new List(Of String)({"a","b"}).ToArray)
to filteredTable variable - now your filteredTable variable will be a table with only columns “a” and “b”
- you can use output data table + write line to print the new table
Sequence: