找不到符号 Workbook.close()
cannot find symbol Workbook.close()
我看到了多个关于此 header 的问题,但没有得到我的答案。
private void createHandBackFile(XSSFSheet sheet, String programId, XSSFWorkbook workbook) throws IOException {
String output = "C:\Users\muddassirr\Downloads\Personal\STORE\Output";
File file = new File(output + File.separator + programId);
if (!file.exists()) {
file.mkdirs();
}
int noOfColumns = sheet.getRow(0).getPhysicalNumberOfCells();
for(int i = 0; i < noOfColumns; i++) {
sheet.autoSizeColumn(i);
}
FileOutputStream outputStream = new FileOutputStream(new File(output + File.separator + programId + File.separator + "HAND_BACK.xlsx"));
workbook.write(outputStream);
outputStream.close();
workbook.close();
}
没有编译错误。但是当我 运行 我得到 运行 时间错误说
java: cannot find symbol
symbol: method close()
location: variable workbook of type org.apache.poi.xssf.usermodel.XSSFWorkbook
我得到了答案。 pom.xml
中缺少此依赖项
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
我看到了多个关于此 header 的问题,但没有得到我的答案。
private void createHandBackFile(XSSFSheet sheet, String programId, XSSFWorkbook workbook) throws IOException {
String output = "C:\Users\muddassirr\Downloads\Personal\STORE\Output";
File file = new File(output + File.separator + programId);
if (!file.exists()) {
file.mkdirs();
}
int noOfColumns = sheet.getRow(0).getPhysicalNumberOfCells();
for(int i = 0; i < noOfColumns; i++) {
sheet.autoSizeColumn(i);
}
FileOutputStream outputStream = new FileOutputStream(new File(output + File.separator + programId + File.separator + "HAND_BACK.xlsx"));
workbook.write(outputStream);
outputStream.close();
workbook.close();
}
没有编译错误。但是当我 运行 我得到 运行 时间错误说
java: cannot find symbol
symbol: method close()
location: variable workbook of type org.apache.poi.xssf.usermodel.XSSFWorkbook
我得到了答案。 pom.xml
中缺少此依赖项<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>