close
http://www.apache.org/dyn/closer.cgi/poi/release/ 下載新版的套件

import org.apache.poi.hssf.usermodel.*;

...
...
//建立活頁簿
HSSFWorkbook wb = new HSSFWorkbook();

//建立工作表
HSSFSheet sheet1 = wb.createSheet ("Patient_Info");
HSSFSheet sheet2 = wb.createSheet ("PSA");

//建立橫行
HSSFRow row = sheet1.createRow (0);

//自動調整欄位寬度
sheet.autoSizeColumn ((short)0);
sheet.autoSizeColumn ((short)1);

//建立儲存格
HSSFCell cell = row.createCell ((short)0);
cell.setCellValue (10);

//建立橫行與儲存格
row = sheet1.createRow (1);
row.createCell ((short)0).setCellValue (546);

//日期格式
HSSFCellStyle cellStyle = wb.createCellStyle ();
cellStyle.setDataFormat (wb.createDataFormat ().getFormat ("yyyy/mm/dd"));
cell = row.createCell ((short)1);
cell.setCellValue (new Date());
cell.setCellStyle (cellStyle);

//儲存
FileOutputStream fso = new FileOutputStream("c:\\downLoad\\tmp.xls");
wb.write (fso);
fso.close ();
arrow
arrow
    全站熱搜

    minkei 發表在 痞客邦 留言(0) 人氣()