Using the Library: poi-src-2.5-final-20040302 reading a XLS-File containing Images is possible. The subsequent creation of a XLS is possible but the file is erroneous. import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; public class ReadWriteWorkbook { public static void main(String[] args) throws IOException { String fp= File.separator; String file = "someFile.xls"; POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream (file)); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.getRow(0); if (row == null) row = sheet.createRow(0); HSSFCell cell = row.getCell((short) 0); if (cell == null) cell = row.createCell((short) 0); cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setCellValue("a test"); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("workbook.xls"); wb.write(fileOut); fileOut.close(); } }
Try the patch I described on bug 28203. Or attach an Excel file (the source) which exhibits the problem. (I.e., we would need "someFile.xls").
Since I've since applied this patch to REL_2_BRANCH I'm closing this. If the problem persists reopen the bug report.