This project has moved. For the latest updates, please go here.

IndexOutOfBounds - new XLWorkbook( ... )

Nov 25, 2014 at 9:13 AM
Hi folks,
I have an error with one of our Excel-Documents. When I call:
wb = new XLWorkbook( path );
I get an IndexOutOfBounds-Exception.

The problem occurs when there is a ',' (comma) in the sheetname. My sheetname for example is EA-Plan, (1.0). I don't know why someone has entered a comma in the sheetname, but it happend.

The exception is thrown in the XLWorkbook_Load.cs file. Line 702, Method: LoadDefinedNames(Workbook workbook).

There is a foreach-loop with a String.Split for comma. This cuts my sheetname in two pieces. So just one piece is send to ParseReference(area, out sheetName, out sheetArea)-Method
        private static void ParseReference(string item, 
                out string sheetName, out string sheetArea)
            var sections = item.Trim().Split('!');
            sheetName = sections[0].Replace("\'", "");
            sheetArea = sections[1];  
The problem is that there is no Index 1 in the sections, since the sheetname was cut in to pieces before.
My question is, why do I have to parse for a comma in the sheetname?
Has this to do with a different culture ?

Kindly Regards,