Bug 49658

Summary: [PATCH] HSSFSHeet after insert EMF,DIB,VMF format Image,Can't open xls for Excel 2007
Product: POI Reporter: longxibo
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.6-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: test insert image xls file
It is dib image
It is wmf image
It is emf image
Patch for embedding EMF files
Patch for embedding EMF files (II)

Description longxibo 2010-07-28 04:27:28 UTC
Created attachment 25807 [details]
test insert image xls file

    public void testInsertImageForHSSF() {
	HSSFWorkbook wb;
	HSSFSheet sheet;
	FileOutputStream foutput = null;
	FileInputStream finput = null;
	String xlsSourceFile = "testfile\\testinsertimage.xls";
	try {
	    finput = new FileInputStream(xlsSourceFile);
	    wb = new HSSFWorkbook(finput);
	    HSSFRow row;
	    sheet = wb.getSheetAt(1);
	    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

	    HSSFClientAnchor anchor;
	    anchor = new HSSFClientAnchor(0, 0, 0, 255, (short) 2, 2, (short) 4, 7);
	    HSSFPicture picture = patriarch.createPicture(anchor, loadPicture("testfile\\test.emf", wb, HSSFWorkbook.PICTURE_TYPE_EMF));
	    // Reset the image to the original size.
	    foutput = new FileOutputStream(xlsSourceFile);
	} catch (FileNotFoundException e) {
	} catch (IOException e) {
	} finally {
	    try {
		if (foutput != null)
	    } catch (IOException e) {
Comment 1 longxibo 2010-07-28 04:29:40 UTC
Created attachment 25808 [details]
It is dib image
Comment 2 longxibo 2010-07-28 04:56:20 UTC
Created attachment 25809 [details]
It is wmf image
Comment 3 longxibo 2010-07-28 04:57:59 UTC
Created attachment 25810 [details]
It is emf image
Comment 4 Nick Burch 2010-07-28 07:03:20 UTC
Can POI still make sense of the image after a save/load?

If you add the same image into the file in excel, how do the BiffViewer outputs differ? Any obvious differences between what POI did and what Excel does?
Comment 5 Egor 2013-05-23 20:17:09 UTC

here said that emf/wmf pictures need special preprocessing before inserting in hssf. Is any info about preprocessing? Where i can read about it?
Comment 6 Andreas Beeker 2013-09-15 12:26:08 UTC
Created attachment 30844 [details]
Patch for embedding EMF files

at least for EMF files, there's no preprocessing of the content required ...

(originally posted here: http://stackoverflow.com/questions/16722044/javapoiinsert-emf-image-into-hssfworkbook/16755335#16755335)
Comment 7 Andreas Beeker 2013-10-12 12:35:05 UTC
Created attachment 30926 [details]
Patch for embedding EMF files (II)

new version which supports EMF/WMF
Comment 8 Yegor Kozlov 2013-10-13 07:21:05 UTC
Patch applied in r 1531622