相关疑难解决方法(0)

Excel工作表的名称长度是否有限制?

当我尝试使用ruby和win32ole使用以下代码设置一个较长的工作表名称时:

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
Run Code Online (Sandbox Code Playgroud)

我得到以下内容:

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 …
Run Code Online (Sandbox Code Playgroud)

excel

64
推荐指数
2
解决办法
10万
查看次数

标签 统计

excel ×1