fastExcel:读取时缺少一列

时间:2012-08-29 02:46:53

标签: java excel

fastexcel是最新的。 首先创建一个xsl文件,然后去读取它,结果显示最后一列丢失了。但是,当我再次保存XLS文档时,最后一列不是最后一列。

生成的代码: java代码

Workbook workBook;  
        workBook = FastExcel.createWriteableWorkbook(xls);  
        workBook.open();  
        int rowsLength = rows.length;  
        int sheets = rowsLength / sheetRows  
                + (rowsLength % sheetRows > 0 ? 1 : 0);  
        int sheetNumber;    
        for (int i = 0; i < sheets; i++) {  
            sheetNumber = i + 1;  
            Sheet sheet = workBook.addStreamSheet(sheetName + sheetNumber);  
//          sheet.addRow(titles);  
            for (int j = i * sheetRows; j < rowsLength; j++) {  
                sheet.addRow(rows[j]);  
                if (j >= sheetRows * sheetNumber) {  
                    break;  
                }  
            }  
        }  
        workBook.close();  

代码读取 java代码

Workbook workBook;  
        workBook = FastExcel.createReadableWorkbook(xls);  
        workBook.setSSTType(BIFFSetting.SST_TYPE_DEFAULT);  
        workBook.open();  
        Sheet s;  
        s = workBook.getSheet(0);  

        excelContent = new String[s.getLastRow()-startRow][];  

        for (int i = startRow; i < s.getLastRow(); i++) {  
            excelContent[i-startRow] = s.getRow(i);  
        }  
        workBook.close();  

1 个答案:

答案 0 :(得分:1)

你可以改变

if (j >= sheetRows * sheetNumber) {  
                    break;  
                }  

if (j >sheetRows * sheetNumber) {  
                    break;  
                }