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 71D27185EB for ; Wed, 16 Sep 2015 14:05:04 +0000 (UTC) Received: (qmail 7164 invoked by uid 500); 16 Sep 2015 14:04:58 -0000 Delivered-To: apmail-poi-dev-archive@poi.apache.org Received: (qmail 7126 invoked by uid 500); 16 Sep 2015 14:04:58 -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 7115 invoked by uid 99); 16 Sep 2015 14:04:58 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Sep 2015 14:04:58 +0000 Received: from asf-bz1-us-mid.priv.apache.org (nat1-us-mid.apache.org [23.253.172.122]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPS id CE9A91A0181 for ; Wed, 16 Sep 2015 14:04:57 +0000 (UTC) Received: by asf-bz1-us-mid.priv.apache.org (ASF Mail Server at asf-bz1-us-mid.priv.apache.org, from userid 33) id A59F8603C8; Wed, 16 Sep 2015 14:04:56 +0000 (UTC) From: bugzilla@apache.org To: dev@poi.apache.org Subject: [Bug 58422] New: How to add image to header of Excel? Date: Wed, 16 Sep 2015 14:04:55 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: POI X-Bugzilla-Component: SXSSF X-Bugzilla-Version: 3.9-FINAL X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pal.ratikanta@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dev@poi.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bz.apache.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 https://bz.apache.org/bugzilla/show_bug.cgi?id=58422 Bug ID: 58422 Summary: How to add image to header of Excel? Product: POI Version: 3.9-FINAL Hardware: PC OS: Windows NT Status: NEW Severity: normal Priority: P2 Component: SXSSF Assignee: dev@poi.apache.org Reporter: pal.ratikanta@gmail.com Hi, I want to add a image to Header of excel .As long I can see all the methods of "org.apache.poi.ss.usermodel.HeaderFooter" class is have string argument .How can I add image to header portion?? Code: ------------------------------------------------------------------------------------- public static void main(String[] args) { try { HeaderFooter vHead = null; int idx = 0; int idy = 0; Cell vFirstCell = null; Cell vLastCell = null; Cell vCell = null; FileOutputStream fileOut = new FileOutputStream("poi-test.xlsx"); SXSSFWorkbook workbook = new SXSSFWorkbook(100); SXSSFSheet worksheet = (SXSSFSheet) workbook.createSheet("POI Worksheet"); vHead = worksheet.getHeader(); InputStream my_banner_image = new FileInputStream("C:\\Users\\RATI\\Desktop\\rati.jpg"); byte[] bytes = IOUtils.toByteArray(my_banner_image); int my_picture_id = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG); my_banner_image.close(); CreationHelper helper = workbook.getCreationHelper(); Drawing drawing = worksheet.createDrawingPatriarch(); ClientAnchor anchor = helper.createClientAnchor(); Picture pict = drawing.createPicture(anchor, my_picture_id); vHead.setCenter(HSSFHeader.font("Times New Roman", "Bold") + HSSFHeader.fontSize((short) 12) + "Rati"); vHead.setRight(HSSFHeader.font("Times New Roman", "Bold") + HSSFHeader.fontSize((short) 8) + "&[Picture]"); // index from 0,0... cell A1 is cell(0,0) Row row1 = worksheet.createRow(idx++); vCell = row1.createCell(idy++); vFirstCell = vCell; vCell.setCellValue("NAME1"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME2"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME3"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME4"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME5"); idy = 0; row1 = worksheet.createRow(idx++); vCell = row1.createCell(idy++); vFirstCell = vCell; vCell.setCellValue("NAME1"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME2"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME3"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME4"); vCell = row1.createCell(idy++); vCell.setCellValue("NAME5"); for (int i = 0; i < 100; i++) { row1 = worksheet.createRow(idx++); idy = 0; for (int j = 0; j < 5; j++) { vCell = row1.createCell(idy++); vCell.setCellValue("TEST--" + i + "--DATA--" + j); vLastCell = vCell; } } for (int i = 0; i < 5; i++) { // worksheet.autoSizeColumn(i); } worksheet.setAutoFilter(new CellRangeAddress(1, 101, 0, 4)); workbook.write(fileOut); fileOut.flush(); fileOut.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } -- 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