Created attachment 25352 [details] a spreadsheet with a single named range with a comment I am trying to read a spreadsheet created in excel 2007 and saved as an "Excel 97-2003 Workbook". Using the new UI for the name manager, I create a Name whose name is "foobarName" and whose comment is "This is a comment". POI claims that the comment for the name is blank. It should be noted that reading the xlsx file, POI correctly returns the comment. I have looked at the xls file produced by excel (attached) and noticed an unknown record (0x894). This seems to be the record intended to store the comment for names. The current implementation of HSSFName#getComment uses the "Description text" field of the NAME record. Unfortunately I have no idea what "Description text" is supposed to contain and so I'm loathed to suggest simply ignoring this field in favour of the NAMECMT record. I am currently working on a patch for support of NAMECMT records but would like to know what the correct behaviour should be.
I think NameCmt may be quite a new thing HSSFName is backed by a NameRecord (sid=0x18), which is called a "Lbl" in the newer Microsoft docs (page 323 in v20091214) HSSFName stores the comment in the DescriptionText field of NameRecord (field 15). Interestingly, the latest docs on Lbl says that the various extra length fields (eg the description) are reserved and must be zero, so clearly Microsoft have changed something at some point. This would explain why new files don't have comments in the same way I'd suggest you add support for the NameCmt record, and update HSSFName to check it if the description text on a NameRecord is of length zero
Created attachment 25705 [details] patch to support 'NameCommentRecord's This patch parses and stores NameCommentRecord records and changes the implementation of HSSFName#getComment to use it's Description text and if that isn't available an associated NameCommentRecord.
Created attachment 25706 [details] test-data file for test added in previous patch A file for testing. This should be placed in test-data/spreadsheet
Thanks for this. Applied in r964845, along with some tweaks to make changes possible, and to support renaming names carrying their comments with them