Closed kennethsantos27 closed 3 months ago
Thanks for the detailed report. That is a bug. I'll look into it.
I've pushed a fix for this issue to main.
I also want to add support for adding user-quoted worksheet names via Worksheet::set_name()
for cases where the current automatic handling isn't sufficient such as worksheet names that contain A1 or RC style reference. So I will leave this open until I fix that as well.
I've pushed a more comprehensive fix to main that also takes into account A1 and RC cell references in the name and also emojis. Basically all the cases in the StackOverflow link you posted.
Fixed on main and in v0.69.0. Thanks for the report.
Current behavior
When opening the workbook in Excel, the print titles are not set correctly for sheets with hyphens (e.g., Sheet-A, Sheet-B-C). The image attached demonstrates that the print titles are not showing up in the Page Setup dialog. Analysis:
The function quote_sheetname currently quotes worksheet names only if they contain spaces, exclamation points, or single quotes. However, worksheet names with hyphens and other characters also need to be quoted to work correctly in Excel.
Current quote_sheetname function:
Expected behavior
Quoting Sheet Names:
The quote_sheetname function should quote sheet names that contain hyphens (-) and other special characters in addition to spaces, exclamation points, and single quotes.
Sheet names like "Sheet-A" and "Sheet-B-C" should be quoted correctly when needed.
Setting Print Titles:
The XML output should properly reflect the quoted sheet names in the elements.
When opening the workbook in Excel, the print titles should be correctly recognized and applied, allowing the user to see and use them in the Page Layout -> Print Titles dialog.
Handling Special Characters:
The function should handle and quote a variety of special characters as mentioned in this StackOverflow discussion, including hyphens and brackets.
Sample code to reproduce
Any other information
We have identified an issue with the quote_sheetname function in the rust-xlsxwriter library where sheet names containing hyphens and certain other characters are not being correctly quoted. This results in Excel not recognizing the print titles specified in the workbook.
Steps to Reproduce:
workbook.xlsx