我尝试使用 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)