美文网首页
POI中创建Sheet时名字长度最好不要超过32个字符

POI中创建Sheet时名字长度最好不要超过32个字符

作者: linweiyu21 | 来源:发表于2017-08-09 11:37 被阅读0次

WorkBook 在创建 Sheet 时,会使用如下代码判断 该 name 是否已存在.

public boolean doesContainsSheetName(String name, int excludeSheetIdx) {
        String aName = name;
        if(name.length() > 31) {
            aName = name.substring(0, 31);
        }

        for(int i = 0; i < this.boundsheets.size(); ++i) {
            BoundSheetRecord boundSheetRecord = this.getBoundSheetRec(i);
            if(excludeSheetIdx != i) {
                String bName = boundSheetRecord.getSheetname();
                if(bName.length() > 31) {
                    bName = bName.substring(0, 31);
                }

                if(aName.equalsIgnoreCase(bName)) {
                    return true;
                }
            }
        }

        return false;
    }

相关文章

网友评论

      本文标题:POI中创建Sheet时名字长度最好不要超过32个字符

      本文链接:https://www.haomeiwen.com/subject/hivfrxtx.html