要保存XSSFWorkbook对象到文件中,可以使用其write方法将内容写入到输出流中,然后关闭文件流。示例如下:
try {
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
workbook.write(fileOut);
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
}
要关闭XSSFWorkbook对象,可以使用其close方法,示例如下:
workbook.close();
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:XSSFWorkbook的加密与解密