This project has moved and is read-only. For the latest updates, please go here.

Can not read any cells if the Excel-file contains a division-by-zero error

Dec 22, 2012 at 2:18 PM
Edited Dec 22, 2012 at 2:18 PM

Say my Excel-file looks like this:

Cell A1: 1
Cell A2: 0
Cell A3: =A1 / A2  

Obviously A3 will result in "#DIV/0!"

However, this also prevents me from reading the content of cell A1:

FileInfo excelFile = new FileInfo(fileName);
ExcelPackage package = new ExcelPackage(excelFile);
var test = package.Workbook.Worksheets[1].Cells[1, 1].Value;

will throw me an "Index was out of range error". If I put a different value in cell A2 the code works just fine.

Is there a way to read the content of cell A1 regardles of any errors elsewhere in the Excel-sheet?