POI的使用
[JAVA_Apache]POI套件的使用_產出EXCEL文件_創建EXCEL裡工作表的方法(Sheet)
產生新的工作表
public static void training3() throws IOException {
FileOutputStream fileOut = null;
try {
// 這裡只純產生新的工作表
// 產出Excel 97(XLS)文件格式
Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
Sheet sheet1 = wb.createSheet("new sheet");
Sheet sheet2 = wb.createSheet("second sheet");
//另外如果是取得原來就有的excel裡的工作表
//方法一 :取得工作表名稱為:工作表1
//wb.getSheet("工作表1");
//方法二 :
//此方法 是要看在excel中的工作表順序
//hssfWorkbook.getSheetAt(0);
fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
finally {
if (null != fileOut) {
fileOut.close();
}
}
}
- 首頁
- JAVA 目錄
- JAVA WEB 目錄
- JAVA 其他未分類 目錄
- Grails目錄
- jQuery 目錄
- Apache 目錄
- JavaScript 目錄
- Spring + Hibernate 目錄
- Hibernate 目錄
- Linux 目錄
- 程式開發工具目錄
- MySQL 目錄
- PHP目錄
- C/C++ 目錄
- Google App Engine 目錄
- HTML5/CSS3
- 程式開發基本資訊
- Android
- Oracle 目錄
- Struts 目錄