I use the following code to read the contents of the xls file using ExcelDataReader.
List<string> excelFiles = GetExcelFileNamesInDirectory(Application.persistentDataPath);
for (int i = 0; i < excelFiles.Count; i++)
{
using (var stream = File.Open(excelFiles[i], FileMode.Open, FileAccess.Read))
{
// Auto-detect format, supports:
// - Binary Excel files (2.0-2003 format; *.xls)
// - OpenXml Excel files (2007 format; *.xlsx)
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
// Choose one of either 1 or 2:
fileLog.text = reader.Name;
// 1. Use the reader methods
do
{
while (reader.Read())
{
// reader.GetDouble(0);
}
} while (reader.NextResult());
// 2. Use the AsDataSet extension method
var result = reader.AsDataSet();
// The result of each spreadsheet is in result.Tables
}
}
}
there is one excel file and hence the code passes the for loop. Unfortunately, the code does not cross the line using (var stream..
and it ends right before creating reader using ExcelReaderFactory. am I missing any reference ?