AsDataSet method returns no values with xls file

Apr 7, 2010 at 10:05 AM

Hi all,

I have a problem using the ExcelDataReader on a Windows 2008 with binary reader.

Simply the driver reports an empty result set. No exceptions, no errors.

I used this code: 

private System.Data.DataSet GetExcelContent(string sourceFileName)
 Excel.IExcelDataReader excelReader = null;
 System.IO.FileStream stream = System.IO.File.Open(sourceFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
 if (sourceFileName.EndsWith(".xlsx"))
  excelReader = Excel.ExcelReaderFactory.CreateOpenXmlReader(stream);
  excelReader = Excel.ExcelReaderFactory.CreateBinaryReader(stream);

 System.Data.DataSet result = excelReader.AsDataSet(false);
 return result;

What am I doing wrong?

Apr 7, 2010 at 10:48 AM

Hi all,

After some testing I discovered that the problem seems to be related to my Excel file.

I has been produced by a commercial toll, so I do not have control on it.

But copying and pasting data onto a new sheet, the driver works fine.

I do not know what happens ... but seems to be related to offsets ...

Thank you