Hi,
I am using poi-3.0-alpha3. I generate a Excel file with Cocoon/Poi HSSF
Serializer, obtaining the inputstream that I want to
modify inserting the image and obtain this file with the image.
In the code I have the following:
............
hssfworkbook = new HSSFWorkbook(inputstream);
HSSFSheet s = hssfworkbook.getSheetAt(0);
HSSFPatriarch patriarch = s.createDrawingPatriarch();
patriarch.createPicture(anchor,
loadPicture("/tmp/images/image.png", hssfworkbook ));
hssfworkbook.write(outputstream);
..........
private static int loadPicture( String path, HSSFWorkbook wb ) throws
IOException{
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
int pictureIndex = 0;
try{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream();
int c;
while ( (c = fis.read()) != -1) bos.write( c );
pictureIndex = wb.addPicture( bos.toByteArray(),
HSSFWorkbook.PICTURE_TYPE_PNG);
} finally{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
The file obtained can't be open. How can I modify the file obtained of
HSSFSerializer in bytes,
inserting a image or Is there other form of implement this insertion
using xml tags, to be serialized after with HSSFSerializer?.
Thanks in advance.
Iris Soto.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/