Excel表单名称的有效字符 [英] Valid characters for Excel sheet names

查看:186
本文介绍了Excel表单名称的有效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,我们使用以下程序包以编程方式创建excel文档:

In Java, we're using the following package to programmatically create excel documents:

org.apache.poi.hssf

如果您尝试设置工作表的名称(NOT文件,但内部的Excel工作表),您将获得如果出现以下错误:

If you attempt to set a sheet's name (NOT file, but internal Excel sheet), you will get an error if:


  • 名称超过31个字符

  • 该名称包含以下任何内容字符:/ \ *? []

然而,创建一个文件名为:

However, after creating a document with a sheet name of:

@#$%&()+〜`':; ... |

@#$%&()+~`"':;,.|

没有错误输出,Java中的所有内容似乎都很好,当您在Office 2003中打开excel文件时,会给您一个错误,表示工作表名称无效,并将其重命名为 Sheet 1。

No error is output, and everything seems fine in Java. When you open the excel file in Office 2003, it will give you an error saying that the sheet name was invalid and that it renamed it to something generic like "Sheet 1".

我不太了解我们使用的以前提到的包,但是看起来它不正确地过滤无效的Excel工作表名称。想法如何过滤掉所有已知的无效字符?我犹豫要简单地过滤所有非字符的字符。

I don't know much about the previously stated package that we're using, but it looks like it's not correctly filtering invalid Excel sheet names. Any idea of how I can filter out all known invalid characters? I'm hesitant to simply filter out all non-word characters.

推荐答案

我认为问题是冒号,而不是感叹号。

I think the problem is the colon, not the exclamation point.

如果您打开Excel并尝试手动编辑工作表名称,则唯一不允许的字符您输入的是[] * / \?:

If you open Excel and try to manually edit a sheet name, the only characters it doesn't let you type are [ ] * / \ ? :

如果您粘贴其中的一个字符,您会收到以下错误:(Excel 2003)

If you paste one of those characters in, you get the following error: (Excel 2003)


在重命名工作表或图表时,您
输入的名称无效。尝试以下
之一:

While renaming a sheet or chart, you entered an invalid name. Try one of the following:


  • 确保您输入的名称不超过31个字符。

  • 确保该名称不包含以下任何
    字符::\ /?


  • 确保你没有留下名字。

  • Make sure the name you entered does not exceed 31 characters.
  • Make sure the name does not contain any of the following characters: : \ / ? * [ or ]
  • Make sure you did not leave the name blank.

这篇关于Excel表单名称的有效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆