If I try what you suggest, the output file is actually corrupted. I can still open the resulting word document in office (the original image is there, but it's no longer an excel embedded file) - I think the image that shows up is a cached image. If I try to open it back in POI, I get all sorts of exceptions.
Looking at the zip files, the embedded xls file shrinks from 86k to 35k. That tells me that the packagePart that is written back is not correct.
Aram On 12/10/2010 10:52 AM, Mark Beardsley wrote:
The approach I tried was this; Open the Word doucment by instntaiting the XWPFDocument class. Get the list of embedded documents. Iteratate through the list to find the embedded workbook. > From the PackagePart, recover an InputStream and use this to create an HSSFWorkbook object that allowed me to manipulate the embedded workbook. > From that same PackagePart, recover an OutputStream. Pass the OutputStream to the write method of the HSSFWorkbook. Finally, call the write method on the XWPFDocument. The resulting Word document was valid - in so far as Word would open it without complaint - but I found that the embedded workbook was now completely empty. All of the workbooks contents had been erased and I am guessing this was caused by the streaming process but cannot be at all certain as I have not investigated further. To date, the only way I have found to successfully update the embedded object is to use a mix of care java code to unzip and then re-zip the docx file and POI to manipulate the embedded workbook. This works but it still leaves the problem of updating the .emf to reflect the changes made to the embedded object. Yours Mark B
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
