Summary: | [PATCH] HSSFSHeet after insert EMF,DIB,VMF format Image,Can't open xls for Excel 2007 | ||
---|---|---|---|
Product: | POI | Reporter: | longxibo |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
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) |
Created attachment 25808 [details]
It is dib image
Created attachment 25809 [details]
It is wmf image
Created attachment 25810 [details]
It is emf image
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? http://mail-archives.apache.org/mod_mbox/poi-user/200710.mbox/%3C1011226198.20071009084134@dinom.ru%3E here said that emf/wmf pictures need special preprocessing before inserting in hssf. Is any info about preprocessing? Where i can read about it? 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) Created attachment 30926 [details]
Patch for embedding EMF files (II)
new version which supports EMF/WMF
Patch applied in r 1531622 |
Created attachment 25807 [details] test insert image xls file @Test 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); finput.close(); 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); anchor.setAnchorType(HSSFWorkbook.PICTURE_TYPE_EMF); HSSFPicture picture = patriarch.createPicture(anchor, loadPicture("testfile\\test.emf", wb, HSSFWorkbook.PICTURE_TYPE_EMF)); // Reset the image to the original size. picture.resize(); picture.setLineStyle(picture.LINESTYLE_DASHDOTGEL); foutput = new FileOutputStream(xlsSourceFile); wb.write(foutput); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (foutput != null) foutput.close(); } catch (IOException e) { e.printStackTrace(); } } }