Is there a limit on an Excel worksheet s name length

0 votes

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?

Dec 19, 2022 in Others by Kithuzzz
• 38,000 points
5,487 views

1 answer to this question.

0 votes
The file format would allow worksheet names to be up to 255 characters long, but if the Excel user interface forbids you from going over 31, don't try to. Giving an app files that are within specs but outside the scope of what the testers would have tested typically results in REALLY bizarre behaviour since the app has weird undocumented limits and idiosyncrasies. (My personal favourite example was when the bold toolbar button in Excel 97 was disabled using the Excel 4.0 bytecode for an if() function in a file with an Excel 97-style stringtable.)
answered Dec 19, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

Is there any way in python to auto-correct spelling mistake in multiple rows of an excel files of a single column?

Use Spellchecker for doing your stuff: import pandas ...READ MORE

answered Oct 14, 2022 in Others by narikkadan
• 63,600 points
2,054 views
0 votes
1 answer

Is there an excel function to tell if a cell has a dependency?

I think there is no built-in function ...READ MORE

answered Jan 21, 2023 in Others by narikkadan
• 63,600 points
863 views
0 votes
1 answer

Is there a way to produce a sum according to date/time stamp values of another column on excel?

Assuming the input data for the second ...READ MORE

answered Mar 25, 2023 in Others by narikkadan
• 63,600 points
613 views
0 votes
1 answer
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,212 views
0 votes
1 answer

ImportError: openpyxl is required for loading excel format files

Forget the PsychoPy complications for the time ...READ MORE

answered Oct 3, 2018 in Python by Priyaj
• 58,020 points
1,078 views
0 votes
1 answer

In Blue Prism how to split excel column data into TWO columns

This is how I am doing it. Dim ...READ MORE

answered Oct 15, 2018 in RPA by Priyaj
• 58,020 points
4,369 views
0 votes
1 answer

Excel Power Query: Using List.MatchAny on a column value

try this. let TableA = ...READ MORE

answered Oct 22, 2018 in Power BI by Annie97
• 2,160 points
4,251 views
0 votes
1 answer

Is there a way to lock cells after editing an excel sheet that's on sharepoint?

The Excel Web version (which, based on ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 63,600 points
1,426 views
0 votes
1 answer

Sort Excel worksheets based on name, which is a date

Sorting sheets of a workbook are rather ...READ MORE

answered Oct 17, 2022 in Others by narikkadan
• 63,600 points
552 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP