Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: IndexOutOfBounds - new XLWorkbook( ... )

$
0
0
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).
Image

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,
Peter

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>