How to do I use a filter to output a data table by column names, but column names is in a list of string and the list can change size?

Example table:
image

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:::

  1. read datatable from excel e.g. to variable called dt
  2. assign New DataView(dt) to a dataview variable
  3. assign dataView.ToTable(false,new List(Of String)({"a","b"}).ToArray) to filteredTable variable
  4. now your filteredTable variable will be a table with only columns “a” and “b”
  5. you can use output data table + write line to print the new table
    image

Sequence:

2 Likes