You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2015/09/16 16:04:55 UTC
[Bug 58422] New: How to add image to header of Excel?
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
[Bug 58422] How to add image to header of Excel?
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58422
--- Comment #1 from Javen ONeal <ja...@gmail.com> ---
You should post this question to the poi-user group [1]. The group is pretty
active and you're more likely to get responses there for usage questions.
We usually only open bugs if we have figured out that POI is missing a feature
or there's a bug in an existing feature.
You may also be interested at looking at some similar open bugs:
bug 53309 - similar request for XSSFWorkbooks
bug 46704 - similar request for HSSFWorkbooks
bug 58237 - similar request for slideshow presentations
[1] http://poi.apache.org/mailinglists.html
--
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
[Bug 58422] How to add image to header of Excel?
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58422
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
I am closing this one as duplicate of the XSSF-related bug as we should be able
to reuse an implementation for both XSSF and SXSSF and thus we should avoid two
places for discussions about this.
*** This bug has been marked as a duplicate of bug 53309 ***
--
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