Hi,
Me again.
So if I understood well the iDataReader feature I commited this piece of code (the DataSet remained for calculating number of rows and columns):
Best regards,
Mike.
Me again.
So if I understood well the iDataReader feature I commited this piece of code (the DataSet remained for calculating number of rows and columns):
FileStream stream = File.Open(ExcelSourceFile, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = Path.GetExtension(ExcelSourceFile).ToLower() == ".xls" ? ExcelReaderFactory.CreateBinaryReader(stream) :ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet ds = new DataSet();
ds = excelReader.AsDataSet();
rows = ds.Tables[0].Rows.Count;
cols = ds.Tables[0].Columns.Count;
int row=0;
while (excelReader.Read())
{
for (int column = 0; column<=cols; column++)
{
DataFromExcel[row, column] = excelReader[column].ToString();
} // this is where code breaks with error: System.NullReferenceException
row++;
}
// DataFromExcel[i, j] =
excelReader.Close();
The error of this code says: System.NullReferenceException. Unfortunately I use VS Express so the debug tool is almost inexisting. At the top of the class there is a declaration:object[,] DataFromExcel;
What I'm missing?Best regards,
Mike.