`

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

    博客分类:
  • JAVA
阅读更多
我在做项目的时候,用ireport的模板导出Excel,就报了下面的错误:
java.lang.IllegalArgumentException: Sheet name cannot be blank, greater than 31 chars, or contain any of /\*?[]

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

所以在以后的开发中,一定要注意这些小细节的问题
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics