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

Exception when creating or loading workbook: When using relative paths, make sure the current directory is correct.

Aug 31, 2013 at 4:43 AM
I'm getting an exception with only a single line of code;
    static void Main(string[] args)
        XLWorkbook workbook = new XLWorkbook(); 
"The type initializer for 'ClosedXML.Excel.XLWorkbook' threw an exception."
"InnerException: When using relative paths, make sure the current directory is correct."

This must be a configuration error? I've added "ClosedXML" and "DocumentFormat.OpenXml" to References. I also get this exception trying to load a workbook.

It has been a frustrating day of Koogra, NPOI, OpenXML! They all seem to have their quirks. All I really want to do is dump the cell contents of every named range in a workbook. With OpenXML I couldn't get it to write dates properly and cycling through each cell in the range was quirky. I've tried multiple StackOverlfow examples.

I Googled the exact text of the exception & it doesn't appear anywhere.

Thanks in advance for any ideas.
Aug 31, 2013 at 11:20 PM
Edited Aug 31, 2013 at 11:21 PM
I was finally able to display dates out of OpenXML, which reminds me-- I'm amazed that you have written your ClosedXML library with so much functionality given the documentation and the difficulty of simple operations in OpenXML! It seems to me that most of the examples for OpenXML involve creating worksheets, not extracting data from them.
Sep 1, 2013 at 7:12 AM
It takes a LOT of patience.

Do this: Create a new project, add the references to ClosedXML and DocumentFormat.OpenXml, put "var wb = new XLWorkbook();" on Main. If you still get the error then create an issue and attach the project so I can see the error for myself.