I have tried: jakarta-poi-1.8.0-dev-20020919.jar jakarta-poi-1.10.0-dev-20030222.jar poi-2.0-pre1-20030517.jar In each case using POI to modify a blank (open Excel press save) spreadsheet created using each of: Excel 2000 (9.0.2720) Excel 2002 (10.2614.2625) resulted in a blank spreadsheet Using other input spreadsheets of varying complexity would result in a corrupt output spreadsheet But generally the result spreadsheet appeared as if it had not been modified This problem does not occur using jakarta-poi-1.5.1-final-20020615.jar Code sample: import java.io.FileInputStream; import java.io.FileOutputStream; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFCell; public class testPOI { public static void main(String[] args) throws java.io.IOException, java.io.FileNotFoundException { // section 1 POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("blank.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); // section 2 //HSSFWorkbook wb = new HSSFWorkbook(); //HSSFSheet sheet = wb.createSheet("new sheet"); HSSFRow row = sheet.getRow(2); if(row == null) row = sheet.createRow((short)2); HSSFCell cell = row.getCell((short)3); if(cell == null) cell = row.createCell((short)3); cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setCellValue("a test"); FileOutputStream fileOut = new FileOutputStream("output.xls"); wb.write(fileOut); fileOut.close(); } }
If however section 1 is commented out and section 2 is enabled causing a new wb and sheet to be created the example works fine with the newer versions of POI
Created attachment 6961 [details] testPOI.java
Created attachment 7283 [details] Excel 2000 blank spreadsheet
Created attachment 7284 [details] Excel 2002 blank spreadsheet
we need to fix this.. I think there is a dupe.
This is still broken in poi-2.0-pre3-20030728.jar
There's a fix in CVS that I just commited that might solve your problem. Try out this jar: http://www.apache.org/~glens/poi-20030921.jar