AsDataSet method returns no values with xls file with compact framework

Sep 28, 2010 at 1:40 AM
Edited Sep 28, 2010 at 1:42 AM

Hi All,

I created an excel file using excel mobile with a device with windows mobile 5.0.  When I use the method AsDataSet does not return any datatable, there is no errors.  The code that i'm using is:


FileStream stream = File.Open(@"\My Documents\Personal\test.xls", FileMode.Open, FileAccess.Read);            

IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);            

excelReader.IsFirstRowAsColumnNames = true;            

DataSet result = excelReader.AsDataSet();            

if (result.Tables.Count > 0)            {                

if (result.Tables["Sheet1"].Rows.Count > 0)                {                  

 InventoryGridInfo gridInfo;                  

 foreach (DataRow row in result.Tables["Sheet1"].Rows)                    {                        

gridInfo = new InventoryGridInfo();                        

foreach (DataColumn column in result.Tables["Sheet1"].Columns)                        {                            

SetData(gridInfo, column.ColumnName, row[column.ColumnName]);                        }                        

inventoryGridCollection.Add(gridInfo);                    }                }            }



When I debug my application, i can see that the file was opened succesfully, because the length of the stream is grater than 0.