Bug 58672 - HSSFName validateName works not as specified (backslash not allowed)
Summary: HSSFName validateName works not as specified (backslash not allowed)
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.14-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2015-11-30 13:42 UTC by Frederik Strelczuk
Modified: 2015-11-30 17:56 UTC (History)
1 user (show)

Fixed validateName (1.27 KB, application/mbox)
2015-11-30 13:42 UTC, Frederik Strelczuk

Note You need to log in before you can comment on or make changes to this bug.
Description Frederik Strelczuk 2015-11-30 13:42:08 UTC
Created attachment 33313 [details]
Fixed validateName

The documentation for HSSFName.setNameName says, that ist ist allowed to use "\" as first character in the name. The function validateName prevents the use of "\" as first character.

Fix is attached as git patch.
Comment 1 Javen O'Neal 2015-11-30 17:56:27 UTC
I tried to find an official Microsoft webpage stating the sheet naming rules but came up short.

This forum [1] mentions there is no official site, but reiterates the error dialog given by Excel when a user tries to enter in an invalid name. I think this may be an incomplete list of rules, for example, a single apostrophe (if this is allowed, I'm guessing some of our CellAddress-related scripts fail when parsing a "'Some Chick'n'!A1". This should be added as a unit test, with expected pass or fail depending on Excel and OpenOffice/LibreOffice behavior).

The Excel error dialog:
"""You typed in an invalid name for a sheet or chart. Make sure that:

The name that you type does not exceed 31 characters.
The name does not contain any of the following characters: : \ / ? *
[ or ]

You did not leave the name blank."""

This forum also mentions the sheet name "History" is off-limits. I wonder if formula names are valid--maybe a formula and a new (sheet name or named range) can be differentiated by the presence of an open parenthesis.

[1] https://social.technet.microsoft.com/Forums/office/en-US/5627d4c3-6023-4ca7-b3d4-f93419e3b560/what-are-the-rules-for-the-name-of-an-excel-worksheet?forum=excel