poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raindog <rain...@macrohmasheen.com>
Subject Re: Extracting a byte[] of a record.
Date Tue, 31 Jan 2012 08:15:37 GMT
On 1/30/2012 11:31 PM, Mark Beardsley wrote:
> Well, if you look at the original examples code, these two lines are the key
> I think;
>
> HSSFObjectData obj : workbook.getAllEmbeddedObjects()
>
> which is actually a shorter way of saying this;
>
> HSSFObjectData[] objs - workbook.getAllEmbeddedObjects();
> for(HSSFObjectData obj : objs) {
> ...
> }
>
> That retrieves all of the embedded onjects as instances of the
> HSSFObjectData class.
>
> Then this line
>
> byte[] objectData = obj.getObjectData();
>
> allows you to get at the data of each embeded object. At it's most basic,
> all I thin you need to so is this;
>
> 1. Get the ambedded objects
> 2. Look at their data and so
>
> HSSFObjectData[] objs - workbook.getAllEmbeddedObjects();
> for(HSSFObjectData obj : objs) {
>      byte[] objectData = obj.getObjectData();
>      byte firstByte = objectData[0];
> }
>
> You do not need any of the other code IMO - unless you are doing something
> more involved. Give those four lines a try and see what happens.
>
> Yours
>
> Mark B
>    


If I do that, the only objects I get are:

Paint.Picture
Packager Shell Object

The length of the byte[] getObjectData returns is 0.

If I iterate over the entires in the Packager Shell Object (which is the 
object containing the embedded exe), I get the following children (The 
last number is object size via DocumentEntry.getSize():
Packager Shell Object.CompObj 76
Packager Shell Object.Ole10Native 180012 <--- these are the bytes I 
want, the Ole10Native entry is not contained in the output from 
workbook.getAllEmbeddedObjects()

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


Mime
View raw message