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

Any install needed on server for EPPlus to work?

Mar 28, 2011 at 10:33 AM
Edited Mar 28, 2011 at 1:31 PM

I have a problem and need some help! :)

Short version: 
Do I need to have something installed on the server for EPPlus.dll to work?

Longer version:
I have used EPPlus when creating an application that reads data from an excel document and populates a database. The uploaded Excel document must follow a specified template. If this template is not followed the user will recieve error messages, depending on what was wrong with the document. One of the things the template requires is for the Excel-document to have 4 worksheets. If the document uploaded by the user doesn't have 4 worksheets an error message is displayed telling the user that the document should have 4 worksheets.

Now, when running the application on my local machine everything works fine. But after having deployed it to my server I get my error message for when the document doesn't have 4 worksheets. So it seems that when on the server EPPlus cannot see that my .xlsx file has 4 worksheets (although it does). It does however pass the part of the code where I check if Workbook is null or not... so it seems like it understand that there is a workbook, but not that there are worksheets... workbook.Worksheets.Count is 0...

On my local machine I have Office excel installed, on my server I do not. Do I need to have something installed on the server for EPPlus.dll to work properly? 

Mar 28, 2011 at 2:36 PM
Edited Mar 28, 2011 at 2:39 PM

I really need some serious help with this. Other people must have come across this too? It works on my local machine (where I have stuff like Microsoft Office installed) but not when deployed to the server (where I do not have Office installed)... any and all help would be much appreciated.

I tried to install Open XML SDK 2.0 for Microsoft Office thinking that might be needed... it did not difference. What am I missing?

Here is some of my code, if that helps anyone to help me, this works locally but not on the server, on the server workBook.Worksheets.Count is 0...

if (file != null)
                //Open and read XLSX file
                using (ExcelPackage package = new ExcelPackage(file))
                    //Get the work book in the file
                    ExcelWorkbook workBook = package.Workbook;
                    if (workBook != null)
                        //Get the worksheets of the document
                        if (workBook.Worksheets.Count != 4)
                            ExcelWorksheet ws_FullService = workBook.Worksheets.ElementAt(0);
                            ExcelWorksheet ws_SMPrices = workBook.Worksheets.ElementAt(1);
                            ExcelWorksheet ws_VisitsPerYear = workBook.Worksheets.ElementAt(2);
                            ExcelWorksheet ws_WheelsPerMonth = workBook.Worksheets.ElementAt(3);

Mar 28, 2011 at 3:40 PM

EPPlus does not require any Office software installed on the machine where you are using it. All it does is reading and writing xml files in the same format as Excel 2007 and higher.

In the code you have provided you are testing if the number of worksheets is anything but 4. Is that your intention?

Mar 28, 2011 at 3:56 PM

Hello, thank you for your reply!

Yes, the admin users have to follow an agreed upon template for the Excel files they upload. This template specified that the document should contian 4 worksheets. This works on my local machine, but not on my server. On the server the worksheets.Counts is 0. Also, if I were to skip that Count check and move on to the workBook.Worksheets.ElementAt(0) part I get that there is no such index. Same if I try .First() or just workBook.Worksheets[1]

As I said, everything works just fine on my local machine... it really does seem like I've missed something when deploying my solution to my server.

Mar 28, 2011 at 4:55 PM

Okay, the solution to this problem was much easier (and more stupid) then I thought.  I made a small test application to try and isolate the issue, and with my test application everything works fine on the server. 

You see, the "part" of my application that reads the excel data is in the form of a plugin ( using Managed Extensibility Framework (MEF)) so it could be easily replaced by some other way of reading the data... anyhow, it seems like the plugin simply doesn't know where to find the EPPlus.dll. So thank you for your time, I loved this library and as usual I hate the configuration involved with deploying my application to the server. :)

Mar 28, 2011 at 5:17 PM
Edited Mar 28, 2011 at 5:19 PM


My best guess would be that you should verify that the path of the existing Excel file is correct on your server. If EPPlus does not find the file it will create a new, blank workbook - which could explain why Worksheets.Count is 0.

Edit: sorry, did not see your last message. Happy coding;)

Jan 29, 2013 at 5:14 PM

thanks for the response.  originally i thought i did not have a pathing issue, but indeed i did.  locally the hardcoded path was fine, and even though the exact same path exists in development, my fully qualiffied path wasn't working.  i changed the hardcoded path to server.mappath and a relative one, and it worked fine.

thanks again,