小编Анд*_*ану的帖子

java.io.EOFException:使用 Apache POI 的 ZLIB 输入流意外结束

我尝试使用 Apache POI 创建 Excel 数据透视表。
目前,当我尝试在工作簿中写入数据时,出现workbook.write(fileOut);异常

org.apache.poi.ooxml.POIXMLException:java.io.EOFException:ZLIB 输入流意外结束

有类的代码:

public class PivotTable {



public static void createPivotTable(String pathToWorkbook, String sheetName) throws IOException {

    Workbook workbook = new XSSFWorkbook(pathToWorkbook);

    XSSFSheet sheet = (XSSFSheet) workbook.getSheet(sheetName);

    int firstRowInd = sheet.getFirstRowNum();
    int lastRowInd = sheet.getLastRowNum();
    int firstCellInd = sheet.getRow(0).getFirstCellNum();
    int lastCellInd = sheet.getRow(0).getLastCellNum() - 1;

    //Specifying top left ant the bottom right of the table data
    CellReference topLeft = new CellReference(firstRowInd, firstCellInd);
    CellReference botRight = new CellReference(lastRowInd, lastCellInd);

    //The area of …
Run Code Online (Sandbox Code Playgroud)

java excel pivot-table exception apache-poi

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

apache-poi ×1

excel ×1

exception ×1

java ×1

pivot-table ×1