Bug 29802 - XLS Read and subsequent write fails if XLS contains Images
Summary: XLS Read and subsequent write fails if XLS contains Images
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: Other All
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on: 28203
Blocks:
  Show dependency tree
 
Reported: 2004-06-25 10:17 UTC by Bernhard Ehrminger
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Ehrminger 2004-06-25 10:17:43 UTC
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();

	}
}
Comment 1 Michael Zalewski 2004-06-25 16:48:38 UTC
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").
Comment 2 Glen Stampoultzis 2004-06-27 11:29:41 UTC
Since I've since applied this patch to REL_2_BRANCH I'm closing this.  If the
problem persists reopen the bug report.