导出Excel java.lang.IllegalArgumentException :Sheet name cannot be blank

我在做项目的时候,用ireport的模板导出Excel,就报了下面的错误:
[color=red]java.lang.IllegalArgumentException: Sheet name cannot be blank, greater than 31 chars, or contain any of /\*?[][/color]

看了poi封装的导出Excel的时候,原来对sheet name有限制,我的那个jasper的名字超过了31个字,顿时让我很郁闷
public void setSheetname( String sheetname )
{
+
+ [color=red]if ((sheetname == null) || (sheetname.length()==0)
+ || (sheetname.length()>31)
+ || (sheetname.indexOf("/") > -1)
+ || (sheetname.indexOf("\\") > -1)
+ || (sheetname.indexOf("?") > -1)
+ || (sheetname.indexOf("*") > -1)
+ || (sheetname.indexOf("]") > -1)
+ || (sheetname.indexOf("[") > -1) )[/color]{
+ throw new IllegalArgumentException("Sheet name cannot be blank, greater
than 31 chars, or contain any of /\\*?[]");
+ }
field_5_sheetname = sheetname;
}

所以在以后的开发中,一定要注意这些小细节的问题

你可能感兴趣的:(JAVA,Excel,Java)