Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: How to Select data from excel using column header in closedXML

$
0
0
Iam using this code for retrieve data from worksheet but i not able filter with column header in this
 var workbook = new XLWorkbook(filePath);
  IXLWorksheet ws1 = workbook.Worksheet(1);
 foreach (IXLRow row in ws1.Rows())
        {
            //Use the first row to add columns to DataTable.
            if (isRequiredHeader)
            {
                foreach (IXLCell cell in row.Cells())
                {
                    dt.Columns.Add(cell.Value.ToString());
                }
                isRequiredHeader = false;
            }
            else
            {
                //Add rows to DataTable.
                dt.Rows.Add();
                int i = 0;
                foreach (IXLCell cell in row.Cells())
                {
                    dt.Rows[dt.Rows.Count - 1][i] = cell.Value.ToString();
                    i++;
                }
            }
        }

It will return full columns, but i need only 2 and 4 th column data having name 'mobile' and 'pincode' how to get whole data for those two columns

Viewing all articles
Browse latest Browse all 1877

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>