No Worksheets found

Jan 9, 2015 at 8:46 AM
Edited Jan 9, 2015 at 11:28 AM
EDIT : After further investigation, the problem was not EPPlus related. My apologies for wasting your time.

Hi,

I am currently facing a weird issue while trying to manipulate an Excel file with EPPlus.
I have a file that I was provided which I managed to succesfully access and read. However, when I open this file with Excel on my computer and then save it, EPPlus does not find Worksheets in the document anymore.

Here is how I manipulate the file :
public static void ImportFile(string filePath) {
            var existingFile = new FileInfo(filePath);

            using (var package = new ExcelPackage(existingFile)) {
                ExcelWorkbook workBook = package.Workbook;
                if (workBook != null) {
                    if (workBook.Worksheets.Count > 0) {
                        ExcelWorksheet currentWorksheet = workBook.Worksheets.First();

                        [...]

                    }
                }
            }
        }
The if statement is successful when I import the file untouched (workBook.Worksheets.Count = 2) and I can manipulate the data.
After opening the Excel file and saving it again without touching data, workBook.Worksheets.Count = 0 which prevents me going further.

I am working on Windows 7 64bit, using the version 4.0.1.1 of EPPlus and the Office365 version of Excel 2013.

If someone has already faced a similar problem, any help would be much appreciated.

Nicolas F
Jan 9, 2015 at 11:25 AM
My bad, the problem was located before trying to read the file. My uploader did not save the file properly which caused the emply worksheet list when reading a non existing file.

This topic can therefore be closed.

Nicolas F
Marked as answer by NicolasSyselio on 1/9/2015 at 4:25 AM