You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by ro...@volny.cz on 2009/09/30 10:42:36 UTC

Embed HSSF into HSLF

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.

Thank you,
Roman



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


Re: Embed HSSF into HSLF

Posted by Yegor Kozlov <ye...@dinom.ru>.
Roman,

I don't have any other ideas how to update an embedded workbook. ObjectData.setData didn't work,
I suspect other places need to be  updated.

The fix will take time. Can you create a bug in Bugzilla and attach a sample file and java code to reproduce the problem?

Yegor

> Hello Yegor,
> Thank you for the fast answer. I tried just to open the workbook and
> write the same data back:
> 
> OLEShape ole = (OLEShape) sh[i];
> HSSFWorkbook wb=new HSSFWorkbook(od.getData());
> ObjectData od=ole.getObjectData();
> ByteArrayOutputStream out = new ByteArrayOutputStream(); 
> wb.write(out); 
> od.setData(out.toByteArray());
> 
> When I open the object in the Powerpoint I get this message: "The server
> application, source file, or item can't be found, or returned as an
> unknown error. You may need to reinstall the server application."
> 
> I also looked into od.storage._data and it is different before and after.
> 
> Can you please try to find another solution?
> 
> Thank you and best regards,
> Roman
> 
> PS: I am using POI 3.5 beta 5 since I get this error in higher versions:
> java.lang.NoSuchMethodError: org.apache.poi.ddf.EscherContainerRecord.getChildIterator()Ljava/util/Iterator;
> org.apache.poi.hslf.model.Sheet.getShapes(Sheet.java:213)
> 
> 
> 
> 
> 
> 
> "Yegor Kozlov" <ye...@dinom.ru> wrote:
> 
>> 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
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Embed HSSF into HSLF

Posted by ro...@volny.cz.
Hello Yegor,
Thank you for the fast answer. I tried just to open the workbook and
write the same data back:

OLEShape ole = (OLEShape) sh[i];
HSSFWorkbook wb=new HSSFWorkbook(od.getData());
ObjectData od=ole.getObjectData();
ByteArrayOutputStream out = new ByteArrayOutputStream(); 
wb.write(out); 
od.setData(out.toByteArray());

When I open the object in the Powerpoint I get this message: "The server
application, source file, or item can't be found, or returned as an
unknown error. You may need to reinstall the server application."

I also looked into od.storage._data and it is different before and after.

Can you please try to find another solution?

Thank you and best regards,
Roman

PS: I am using POI 3.5 beta 5 since I get this error in higher versions:
java.lang.NoSuchMethodError: org.apache.poi.ddf.EscherContainerRecord.getChildIterator()Ljava/util/Iterator;
org.apache.poi.hslf.model.Sheet.getShapes(Sheet.java:213)






"Yegor Kozlov" <ye...@dinom.ru> wrote:

> 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
> 



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


Re: Embed HSSF into HSLF

Posted by Yegor Kozlov <ye...@dinom.ru>.
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


Re: Embed HSSF into HSLF

Posted by "Zachary Mitchell, BCIS" <za...@internode.on.net>.
Sorry, probably not me! My Professional needs don't
include using POI with powerpoint.

----- Original Message ----- 
From: <ro...@volny.cz>
To: <us...@poi.apache.org>
Sent: Wednesday, September 30, 2009 6:12 PM
Subject: Embed HSSF into HSLF


> 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.
> 
> 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