WritableWorkbook workbook = Workbook.createWorkbook(new File("output.xls")); WritableSheet sheet = workbook.createSheet("First Sheet", 0); Label label = new Label(0, 2, "A label record"); sheet.addCell(label); Number number = new Number(3, 4, 3.1459); sheet.addCell(number); workbook.write(); workbook.close();
http://www.andykhan.com/jexcelapi/tutorial.html
经过研究源码发现, 如果workbook是用 WritableWorkbook createWorkbook(OutputStream output) 方法生成的,则workbook.close()后,相应的output也会被自动关闭