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

Error while reading Excel: Sequence contains no elements

Feb 13, 2012 at 10:45 AM

I recently switched from vs 2008 to vs 2010. In vs2008 I used EPPlus a lot to read and write to excel from websites. In the next peace of (red) code I get the error: Sequence contains no elements

 Dim myToepassing As New ExcelPackage(myFile)
 Dim myWorkbook As ExcelWorkbook = myToepassing.Workbook
 Dim werkblad As ExcelWorksheet = myWorkbook.Worksheets.First()

The excel has 3 worksheets. I used to do this in my vs2008 projects without a problem. Can someone tell me what I do wrong or what need to be changed? I downloaded the latest version of epplus

Feb 16, 2012 at 8:38 PM

You have no worksheets in the worksheets collection.

I would guess the myFile path does not point at your template file. (Check the myFile.Exists property)