Bool is not parsed in the DataTable.

Aug 10, 2011 at 6:59 PM

Please help its very needed currently.

The output databale does not have the bool which i am looking for.



The excel file is not able to read this record, the follwoing code which gives me the data table it has bool conversions (True,False) which are not represented in the datatable. its all blank and null

           FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read);

            //1. Reading from a binary Excel file ('97-2003 format; *.xls)
            IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
            //1. Reading from a OpenXml Excel file (2007 format; *.xlsx)
            //IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
            //3. DataSet - Create column names from first row
            excelReader.IsFirstRowAsColumnNames = true;
            DataSet result = excelReader.AsDataSet();

            return result.Tables[tableName];

If you want i can send you a sample file.


Kind Regards


Aug 10, 2011 at 7:36 PM

Here is the Test.

        public void excelReaderReadBoolDefault()
            IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(Helper.GetTestWorkbook("Test_num_double_date_bool_string"));

            DataTable result = excelReader.AsDataSet().Tables[0];

            Assert.AreEqual(result.Rows[22][3], true);


should be able to get this one as a bool or even as a string to get the value in the cell. its fine with me if every thing is treated as a string also.

Aug 10, 2011 at 8:32 PM
Edited Aug 10, 2011 at 8:35 PM
private bool readWorkSheetRow()
			m_cellsValues = new object[m_maxCol];

			while (m_cellOffset < m_stream.Size)
				XlsBiffRecord rec = m_stream.ReadAt(m_cellOffset);
				m_cellOffset += rec.Size;

				if ((rec is XlsBiffDbCell)) { break; };//break;
				if (rec is XlsBiffEOF) { return false; };

				XlsBiffBlankCell cell = rec as XlsBiffBlankCell;
				//rec.ID ==   ID BOOLERR Excel.Core.BinaryFormat.BIFFRECORDTYPE
if ((null == cell) || (cell.ColumnIndex >= m_maxCol)) continue; if (cell.RowIndex != m_depht) { m_cellOffset -= rec.Size; break; }; pushCellValue(cell); } m_depht++; return m_depht < m_maxRow; }
Thats the place its failing its not treating the cell for some reason as a correct cell.
Its very difficult for me to understand the offset Excel notations. 
All i wanted is a datatable to traverse.
It's working fine for all the other cells only for these ones its showing some thing very different.
Kind regards