I’d like to report a bug in the Cell class. This has to do with the custom style formats available. I was making some experiments with the cells in a sheet and came through this bug.
It happens I have some cells that need special formatting: they need to have 2 single quotes after the value: #,##0’'
It works well, the values are displayed correctly and so on. If I try to access this cell StringValue, that exception occurs. Not a big deal so far, I can manage a workaround. The problem arises when I try to autofit the rows or columns when one (or more) of their cells contain a cell with this custom style. As I suppose, the autofit methods use the StringValue to calculate the maximum width (or height) of all cells in the selected range, so it can set the row height or column width to that value. But because there are cells in the range that throw an exception when reading their StringValues, the autofit methods themselves also throw the same exception. While I can still manage a workaround to autofit the rows and columns myself, it is a bunch of work that I would like to avoid, as you can imagine.
Did you had knowledge of this bug? Is it easily fixed?
Thanks in advance,
Thanks for reporting,
After implementing your scenario, we can reproduce the System.IndexOutOfRangeException for Cell.StringValue and Worksheet.AutoFitColumn(s) methods etc.
We will figure it out soon.
Please try this attached fix.
Ok, it is fixed! Thanks