http://poi.apache.org/spreadsheet/how-to.html#sxssf
Reading or modifying an existing file 샘플
http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
읽고쓰기
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) {
}
}
}
poi-3.9-20121203.jar
ExcelTest.java
read.xls