|
|||
|
Has anyone here been able to save a spreadsheet in 2007 document format with an image inserted? When I try it the image is not saved with the document.
I don't have any problems when saving to 97-2003 format. sample code: Document document = null; BookModel bm = null; FileInputStream inStream = null; File file = null; try { document = new Document(null); bm = BookModel.Factory.create(document.getBook()); bm.initWorkbook(); bm.getBook().setNumSheets(1); bm.setSheet(0); DrawingModel dm = bm.getDrawing(); inStream = new FileInputStream("C:\\xl\\image.jpg"); //<--replace with your own image ShapeAnchor shapeAnchor = dm.createShapeAnchor(1, 1, 5, 10); shapeAnchor.setPlacementStyle(ShapeAnchor.eMove); Shape newShape = dm.addPicture(inStream, shapeAnchor); newShape.setName("IMAGE.1"); //save the document to 2003 and 2007 format file = new File("C:\\imageTest.xls"); document.fileSaveCopyAs(file, DocumentType.EXCEL_97_WORKBOOK, null); file = new File("C:\\imageTest.xlsx"); document.fileSaveCopyAs(file, DocumentType.OPEN_XML_WORKBOOK, null); } finally { inStream.close(); document.release(); } |
![]() |
| Thread Tools | |
| Display Modes | |
|
|