Here is a snippet of my code:
string filePath = @"C:\DRMF.xls";
FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
excelReader.IsFirstRowAsColumnNames = true;
DataSet results = new DataSet();
DataTable testSheet = new DataTable();
testSheet = results.Tables.Add("test");
results = excelReader.AsDataSet();
I had assumed that once I added the datatable “test” to the dataset, that any data that I loaded into the dataset would automatically load into the datatable “test”. That doesn’t appear to be the case. It is loading, instead, into a datatable called “Sheet1” which I assume it is getting from the Excel spreadsheet.
So, my question is, once I have the data in my dataset, how can I get it into the “test” datatable?
Try something like this:
This way, you have the data loaded and then you can change the table name to whatever you want and not have to create extra tables.