cancel
Showing results for 
Search instead for 
Did you mean: 

Image in export to excel using hssf api

Former Member
0 Kudos

Im trying to create a excel sheet in webdynpro java using hssf api.
I am able to format the excel as per the requirement, and im facing a problem while adding a image(logo).
Iam using the following code:

FileInputStream fis=new FileInputStream("M:\\image.JPG");
ByteArrayOutputStream img_bytes=new ByteArrayOutputStream();
int b;
while((b=fis.read())!=-1)
img_bytes.write(b);
fis.close();
HSSFClientAnchor anchor = new
HSSFClientAnchor(0,0,0,0,(short)col,row,(short)++col,++row);
int index=wb.addPicture(img_bytes.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG);
HSSFSheet sheet=wb.getSheet("test");
HSSFPatriarch patriarch=sheet.createDrawingPatriarch();
patriarch.createPicture(anchor,index);
anchor.setAnchorType(2);
wb.write(fos);
System.out.println("Writing data to the xls file");
fos.close();
System.out.println("File closed");

But doesnt work. Can anyone suggest where im going wrong?

Regards,
Padmalatha.

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

FileInputStream fis=new FileInputStream("M:\\image.JPG");

are you sure the path is right?