package poitest;

import java.io.FileOutputStream;
import java.util.Date;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;


public class Sample3 {

	public static void main(String[] args) throws Exception{

		//ワークブックとシートを作る
		HSSFWorkbook wb = new HSSFWorkbook();
		HSSFSheet sheet = wb.createSheet("sheet1");

		//１行目に整数、少数、文字、Boolean、日付を入れる		
		HSSFRow row = sheet.createRow((short)0);

		row.createCell((short)0).setCellValue(1);
		row.createCell((short)1).setCellValue(6.9);
		row.createCell((short)2).setCellValue("STRING");
		//cell.setEncoding(HSSFCell.ENCODING_UTF_16);//文字列が日本語の場合
		row.createCell((short)3).setCellValue(true);

		HSSFCellStyle cellStyle = wb.createCellStyle();
		cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));
		HSSFCell cell = row.createCell((short)4);
		cell.setCellValue(new Date());
		cell.setCellStyle(cellStyle);


		FileOutputStream fileOut = new FileOutputStream("tmp/hoge.xls");
		wb.write(fileOut);
		fileOut.close();		

		System.out.println("END");
	}
}

