Selecting subset of columns from a datatable

c#

Solution

You can use `DefaultView.ToTable` for this:

var table = table.DefaultView.ToTable(false, "Column1", "Column2", "Column3");

Here's the documentation: DefaultView.ToTable Method

Problem

I have a dataset of 15 columns. I want to generate an excel sheet with only 4 columns of that dataset. How can we select a subset of columns in to a datatable? Thanks, Rohit

Original source