http://poi.apache.org/spreadsheet/how-to.html#sxssf
Reading or modifying an existing file 샘플
읽고쓰기
FileOutputStream fos = null;
try
{
HSSFWorkbook workbookTest;
HSSFSheet activeSheetTest;
FileInputStream fis = new FileInputStream( "write.xls");
workbookTest = new HSSFWorkbook(fis);
activeSheetTest = workbookTest.getSheetAt(0);
// 저장할 위치를 확인한다.
File file = new File(targetPath);
HSSFRow row = activeSheetTest.getRow(0);
// 처리결과 쓰기
HSSFCell cell = row.getCell(1);
//cell.getStringCellValue();
//System.out.println(" cell.getStringCellValue()= " + cell.getStringCellValue() );
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(new HSSFRichTextString("111"));
// 오류내용 쓰기
cell = row.getCell(2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(new HSSFRichTextString("222"));
// 저장경로에 엑셀파일을 저장한다.
fos = new FileOutputStream(targetPath);
workbookTest.write(fos);
}
catch ( Exception e )
{
System.out.println(e);
}
finally
{
if ( fos != null ) {
try {
fos.close();
}
catch(Exception e) {
}
}
}
'JAVA OPEN API' 카테고리의 다른 글
[ibatis] 여러개 resultMap 과 groupBy 사용 예제 (0) | 2013.08.22 |
---|---|
[ibatis] map 으로 파라미터 받기 (0) | 2013.07.15 |
[POI] RecordFormatException: Unable to construct record instance 오류 (0) | 2013.07.02 |
sitemesh.xml 설정 (0) | 2013.06.19 |
[ibatis] in 처리 (0) | 2013.06.17 |