Return-Path: X-Original-To: apmail-poi-dev-archive@www.apache.org Delivered-To: apmail-poi-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D41D442C for ; Fri, 1 Jul 2011 10:42:24 +0000 (UTC) Received: (qmail 47649 invoked by uid 500); 1 Jul 2011 10:42:24 -0000 Delivered-To: apmail-poi-dev-archive@poi.apache.org Received: (qmail 47375 invoked by uid 500); 1 Jul 2011 10:42:17 -0000 Mailing-List: contact dev-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Developers List" Delivered-To: mailing list dev@poi.apache.org Received: (qmail 47354 invoked by uid 99); 1 Jul 2011 10:42:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2011 10:42:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.115] (HELO eir.zones.apache.org) (140.211.11.115) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2011 10:42:13 +0000 Received: by eir.zones.apache.org (Postfix, from userid 80) id 2CBCA48ED4; Fri, 1 Jul 2011 10:41:53 +0000 (UTC) From: bugzilla@apache.org To: dev@poi.apache.org Subject: DO NOT REPLY [Bug 51459] New: Image not added in HSSFWorkbook Date: Fri, 01 Jul 2011 10:41:51 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: POI X-Bugzilla-Component: HSSF X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: martin.studer@mirai-solutions.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dev@poi.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: https://issues.apache.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 https://issues.apache.org/bugzilla/show_bug.cgi?id=51459 Bug #: 51459 Summary: Image not added in HSSFWorkbook Product: POI Version: 3.8-dev Platform: PC Status: NEW Severity: normal Priority: P2 Component: HSSF AssignedTo: dev@poi.apache.org ReportedBy: martin.studer@mirai-solutions.com Classification: Unclassified Created attachment 27235 --> https://issues.apache.org/bugzilla/attachment.cgi?id=27235 Excel file for reproducing the issue Trying to add an image to a worksheet does not actually work in the case of the attached Excel file (repro.xls). There is no error message - the image just won't end up on the worksheet. I could pin the problem down to the second worksheet (note, the image is to be added to first one). If I delete the second worksheet, it works. Originally, there were many more worksheets in the workbook and I tried deleting any of them in succession to detect where the issue is and it seems that exactly the remaining (worksheet 2 in repro.xls) is causing the grief. The following is the code to reproduce the issue: File f1 = new File("repro.xls"); File f2 = new File("earthquake.jpg"); HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(f1)); InputStream is = new FileInputStream(f2); byte[] bytes = IOUtils.toByteArray(is); int imageIndex = wb.addPicture(bytes, org.apache.poi.ss.usermodel.Workbook.PICTURE_TYPE_JPEG); is.close(); Name cname = wb.getName("Test"); Sheet sheet = wb.getSheet(cname.getSheetName()); AreaReference aref = new AreaReference(cname.getRefersToFormula()); CellReference topLeft = aref.getFirstCell(); CellReference bottomRight = aref.getLastCell(); Drawing drawing = null; drawing = ((HSSFSheet)sheet).getDrawingPatriarch(); if(drawing == null) { drawing = sheet.createDrawingPatriarch(); } CreationHelper helper = wb.getCreationHelper(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setRow1(topLeft.getRow()); anchor.setCol1(topLeft.getCol()); anchor.setRow2(bottomRight.getRow() + 1); anchor.setCol2(bottomRight.getCol() + 1); anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE); drawing.createPicture(anchor, imageIndex); FileOutputStream fos = new FileOutputStream(f1, false); wb.write(fos); fos.close(); I'm using POI 3.8-beta3 with a 64-bit JDK 1.6.0_20 on Windows 7 64-bit. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org For additional commands, e-mail: dev-help@poi.apache.org