Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
fix: NumberFormatException if XSSFName.setNameName is set with a long name #55
If you call XSSFName.setNameName with a long value consisting of a letter followed by a big number, you will get a NumberFormatException.
The reason for the NumberFormatException:
In the next step, row will be converted into a number using Integer.parseInt. But the current row value exceeds the max value of an Integer resulting in a NumberFormatException.
Since the logic is fine, I replaced Integer.parseInt with BigDecimal, so there is no problem with parsing big numbers anymore.
The reason is described here (https://support.office.com/en-us/article/Define-and-use-names-in-formulas-4d0f13ac-53b7-422e-afd2-abd7ff379c64, Section "Learn about syntax rules for names"):
Cell references disallowed: Names cannot be the same as a cell reference, such as Z$100 or R1C1.
Thus, you have to validate that the given name is not a cell reference.
How about private XSSFName.validateName swallows the NumberFormatException?
This will means that public CellReference.cellReferenceIsWithinRange will continue to raise a NFE if it gets a silly input, letting the caller decide how to handle a non-integer row string.