Return-Path: X-Original-To: apmail-poi-user-archive@www.apache.org Delivered-To: apmail-poi-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E22979624 for ; Tue, 12 Jun 2012 13:58:08 +0000 (UTC) Received: (qmail 26791 invoked by uid 500); 12 Jun 2012 13:58:08 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 26751 invoked by uid 500); 12 Jun 2012 13:58:08 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Delivered-To: moderator for user@poi.apache.org Received: (qmail 16556 invoked by uid 99); 12 Jun 2012 13:54:41 -0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of flavio.cimolin@cd-adapco.com designates 209.85.214.46 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cd-adapco.com; s=google; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :content-type; bh=KZgdeu/06IqmDHef4qZ4UALM48ZhhX8O7MxQH2uXStg=; b=NM6SkxwndV4OEtyiS+AWuJlLJfOO3TmbKUq6MKukcvJ7akIL1Xzdm4psBFcD4H4NeI 055vCgPzN86zegOgI2HWQ3jB4FV0/4JGRpWAKN0A+LOs5xnJL9SLqvvZZwlJj6hRnFw0 rCAwnyPGblBEID0aVFd5Wf3Gp2sbGxGOnyFOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :content-type:x-gm-message-state; bh=KZgdeu/06IqmDHef4qZ4UALM48ZhhX8O7MxQH2uXStg=; b=JfV0pSmwmc7lDXXjHre0Gau08OZd0ibr4yCQI4gXpi8b8r5Ubgn/5wfMpBG6vfAA6F xf+cKgFz/0Ryx8IrFgfZYMTt0zVjxlcrcJvZd7C4rB2lLPTSUzVzG4bzTdQl0v8a+uJi Y/CEY+HQ9zd/YKCRLhVr4cuyf5wQbISoOBnMWFN4d81w2v7ds2R+nDYp7Od5rYEcmkfJ C041+JWTGac/CnRJ5okjgQbmD3Twnve4tPKU+Nywvom+3TBmqZ2An3v5JC8xhSrQnviL VfoVwOxkNcw1CP9BHOso+puED8VZ8XMQBOvkvlx5ldL4Yl6s5KA/smpjz9vWvRRxFcuP g3Qw== Message-ID: <4FD74A04.9060106@cd-adapco.com> Date: Tue, 12 Jun 2012 15:54:12 +0200 From: Flavio Cimolin Reply-To: flavio.cimolin@cd-adapco.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: user@poi.apache.org Subject: Problem with inserting images after saving an HSSFWorkbook Content-Type: multipart/alternative; boundary="------------000503090105070002080305" X-Gm-Message-State: ALoCoQmW1XVc/XPnSMunoF57UOQ2trgh2Sex+2pVl1S9Vxt9P0W/KxFDjIiTNrdhkAqOUqNeQew6 X-Virus-Checked: Checked by ClamAV on apache.org --------------000503090105070002080305 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Hello, I can't understand an issue related to inserting images in an HSSFWorkbook. In the example below, if I save a copy of the Workbook before inserting the second image, the final saved file doesn't display the second image. On the other hand, if I don't perform the intermediate saving, the final file is correctly saved as expected. I have highlighted with asterisks the portion of code that gives the problem when uncommented: try { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Sheet 1"); CreationHelper helper = wb.getCreationHelper(); Drawing drawing = sheet.createDrawingPatriarch(); { InputStream is = new FileInputStream(resolvePath("imm1.png")); byte[] bytes = IOUtils.toByteArray(is); int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); is.close(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setRow1(1); anchor.setCol1(2); Picture pict = drawing.createPicture(anchor, pictureIdx); pict.resize(); } // *************************************************************************************************** // FileOutputStream fileOut1 = new FileOutputStream(sim.getSessionDir() + File.separator + "example_image_1.xls"); // wb.write(fileOut1); // fileOut1.close(); // *************************************************************************************************** { InputStream is = new FileInputStream(resolvePath("imm2.png")); byte[] bytes = IOUtils.toByteArray(is); int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); is.close(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setRow1(14); anchor.setRow2(1); Picture pict = drawing.createPicture(anchor, pictureIdx); pict.resize(); } FileOutputStream fileOut2 = new FileOutputStream(sim.getSessionDir() + File.separator + "example_image_2.xls"); wb.write(fileOut2); fileOut2.close(); } catch (IOException ex) { sim.println(ex); } Thanks in advance for telling me whether I am making something wrong or it is a bug... Regards, Flavio -- Flavio Cimolin Technical Support Engineer CD-adapco, Turin Office phone: +39 011 562 2194 (int 413) email: flavio.cimolin@cd-adapco.com web: http://www.cd-adapco.com --------------000503090105070002080305--