3、 fileOut.close(); 24. 25.3.创建单元格(CELL) 26. 27. HSSFWorkbook wb = new HSSFWorkbook(); 28. 29. HSSFSheet sheet = wb.createSheet("new sheet"); 30. 31. // Create a row and put some cells in it. Rows are 0 based. 32. 33. HSSFRow row = sheet.createRow((s
4、hort)0); 34. 35. // Create a cell and put a value in it. 36. 37. HSSFCell cell = row.createCell((short)0); 38. 1. cell.setCellValue(1); 2. 3. // Or do it on one line. 4. 5. row.createCell((short)1).setCellValue(1.2); 6. 7. row.createCell(
5、(short)2).setCellValue("This is a string"); 8. 9. row.createCell((short)3).setCellValue(true); 10. 11. // Write the output to a file 12. 13. FileOutputStream fileOut = new FileOutputStream("workbook.xls"); 14. 15. wb.write(fileOut); 16. 17. fileOut
6、.close(); 18. 19.4.创建指定单元格式的单元格 20. 21. HSSFWorkbook wb = new HSSFWorkbook(); 22. 23. HSSFSheet sheet = wb.createSheet("new sheet"); 24. 25. // Create a row and put some cells in it. Rows are 0 based. 26. 27. HSSFRow row = sheet.createRow((short)0);
7、 28. 29. // Create a cell and put a date value in it. The first cell is not styled 30. 31. // as a date. 32. 33. HSSFCell cell = row.createCell((short)0); 34. 35. cell.setCe