poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yegor Kozlov <ye...@dinom.ru>
Subject Re: Embed HSSF into HSLF
Date Wed, 30 Sep 2009 09:15:01 GMT
roman.durdik@volny.cz wrote:
> Hello all,
> I am trying to create PPT slide which will contain excel workbook. What
> I can do is that I create the excel object in the Powerpoint template
> and then I can read it like this:
> 
> OLEShape ole = (OLEShape) sh[i];
> ObjectData od=ole.getObjectData();
> HSSFWorkbook wb=new HSSFWorkbook(od.getData());
> HSSFSheet excelSheet=wb.getSheetAt(0);
> HSSFRow row=excelSheet.getRow(0);
> HSSFCell cell=row.getCell(0);
> 
> Everything works well up to now. Then I would like to write some new
> data: cell.setCellValue("hello"); which works as well.
> 
> But now I would like to write the excel workbook back to the powerpoint
> slide.
> 
> Could you please help me? I don't have any idea how to do it.
> 

Try to serialize the workbook in a byte array and push the bytes back to ObjectData :

ByteArrayOutputStream out = new ByteArrayOutputStream();
wb.write(out);
od.setData(out.toByteArray());

Yegor


> Thank you,
> Roman
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message