[java excel api] 写工作表的代码


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也会被自动关闭

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.