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

No worksheets in file?

Apr 15, 2016 at 9:44 PM
Edited Apr 15, 2016 at 10:12 PM
Apparently EPPlus doesn't support .xls, only the XML format? That's a question because I've been all over the CodePlex project site looking into this and not found any explicit statement of this fact. If it's spelled out somewhere, it's not anywhere obvious. You might want to look at putting that somewhere on the home page, in big bold font. Would have saved me some time today. :)

I've tried several files, and EPPlus v4.0.5 (latest per nuget) seems to be unable to read any worksheets from any excel files I try to load using the following code.

Am I doing something wrong?
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)

            var fi = new System.IO.FileInfo(@"c:\tmp\book1.xls");
            var package = new ExcelPackage(fi);
            var book = package.Workbook;
            Console.WriteLine("book.Worksheets Count: {0}", book.Worksheets.Count);
            if(book.Worksheets.FirstOrDefault() == null)
                Console.WriteLine("book.Worksheets.FirstOrDefault() is null.");

Apr 20, 2016 at 2:29 PM
Edited Apr 20, 2016 at 2:29 PM
Home page title for this project: "Create advanced Excel 2007/2010 spreadsheets on the server".

Not sure it could be much clearer.

The legacy Excel 98/2000 XLS format ("BIFF" format) is not supported by EPPlus, it's wildly different from the OOXML (aka "XLSX") format that EPPlus is built around.

To read or write old XLS files, I would recommend the NPOI library. It doesn't have the same level of functionality as EPPlus, but it works just fine for reading and writing old Excel files. But that library also doesn't support either the Excel 2002/2003 XML format or the 2007/2010/2013/2016 OOXML format, so if you're dealing with legacy Excel files from many sources, you'll need to use multiple libraries.