When I try to set a longish worksheet name using ruby and win32ole with the following code:
require "win32ole"
excel = WIN32OLE.new('Excel.Application')
excel.Visible = 1
puts excel.version
workbook = excel.Workbooks.Add
worksheet1 = workbook.Worksheets.Add
worksheet1.Name = "Pseudopseudohypoparathyroidism" #Length 30, fine
worksheet2 = workbook.Worksheets.Add
worksheet2.Name = "Supercalifragilisticexpialidocious" #Length 34, not fine
I get the following:
12.0
-:9:in `method_missing': (in setting property `Name': ) (WIN32OLERuntimeError)
OLE error code:800A03EC in Microsoft Office Excel
You typed 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.
HRESULT error code:0x80020009
Exception occurred.
from -:9:in `<main>'
Although Excel 2007 is listed as being installed, version 12.0 complains that the worksheet name is too long. I looked at Excel 2007's requirements and limitations as described in this related response, but I was unable to locate any reference of this limit. (Attempting to manually rename a worksheet indicates there might be a limit, but)
Exists a limit, and if so, can it be modified by adjusting Excel's settings, or is it a hard restriction?