Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all articles
Browse latest Browse all 448

New Post: "Define Name" as DataSet from Excel file

$
0
0
Using xUnit, I can refer to a file, and use a "Select * from [Defined Name]" where Defined Name is the area in the spreadsheet that was highlighted and assigned the Define Names to it. This allows the selection to be treated like a sql dataset.
How can I refer to this selection in IExcelDataReader?
If it doesn't exist, can you make this modification as a suggestion?

Also, I cannot find any reference on how to refer to the data via the column name. You have the following available:
excelReader.IsFirstRowAsColumnNames = true;

However, I cannot seem to find an example on how to reference the column names while looping through the data.

For example:
            FileStream stream = File.Open(testFileName, FileMode.Open, FileAccess.Read);
            IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
            excelReader.IsFirstRowAsColumnNames = true;
            DataSet testData = excelReader.AsDataSet();

            string salesRepName;

            while (excelReader.Read())
            {
                salesRepName = excelReader["SalesRepName"].value;
                salesRepId = excelReader["SalesRepId"].value;
           }

Viewing all articles
Browse latest Browse all 448

Trending Articles



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