I had a problem last year with Excel (for Mac 201) having to repair my workbook and then having a worksheet with the name along the lines Repaired sheet ("Återskapad_Blad1" in Swedish). When it happened to me again now I realized that it was a colon (:) that caused it to be broken. Apparently there are (at least) seven different characters that are disallowed in worksheet names and that Excel won't let you enter if you do it manually.
require 'rubyXL'
workbook = RubyXL::Workbook.new
# List based on http://www.accountingweb.com/technology/excel/seven-characters-you-cant-use-in-worksheet-names
# Added @ as example of character without this problem
chars = '@\\/*[]:?'
chars.each_char do |char|
worksheet = workbook.add_worksheet("Test sheet #{char}")
worksheet.add_cell(0, 0, "Test sheet #{char}")
end
workbook.write("illegal-chars.xlsx")
If I open this file in my version of Excel (Mac, v. 14.6.4) I now see:
("Återskapad_Blad" meaning "Recreated sheet" in Swedish)
Apparently Excel replaces [ and ] with ( and ) respectively but first after it has complained about a corrupt file and asked to repair it.
I personally haven't made up my mind if I would like rubyXL to just silently remove these characters or raise an exception.
I had a problem last year with Excel (for Mac 201) having to repair my workbook and then having a worksheet with the name along the lines Repaired sheet ("Återskapad_Blad1" in Swedish). When it happened to me again now I realized that it was a colon (:) that caused it to be broken. Apparently there are (at least) seven different characters that are disallowed in worksheet names and that Excel won't let you enter if you do it manually.
If I open this file in my version of Excel (Mac, v. 14.6.4) I now see:
("Återskapad_Blad" meaning "Recreated sheet" in Swedish)
Apparently Excel replaces [ and ] with ( and ) respectively but first after it has complained about a corrupt file and asked to repair it.
I personally haven't made up my mind if I would like rubyXL to just silently remove these characters or raise an exception.