public class UpdateEmbeddedDoc extends Object
This code was successfully tested with the following file from the POI test collection: http://svn.apache.org/repos/asf/poi/trunk/test-data/document/EmbeddedDocument.docx
| Constructor and Description |
|---|
UpdateEmbeddedDoc(String filename)
Create a new instance of the UpdateEmbeddedDoc class using the following
parameters;
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkUpdatedDoc()
Called to test whether or not the embedded workbook was correctly
updated.
|
static void |
main(String[] args)
Code to test updating of the embedded Excel workbook.
|
void |
updateEmbeddedDoc()
Called to update the embedded Excel workbook.
|
public UpdateEmbeddedDoc(String filename) throws FileNotFoundException, IOException
filename - An instance of the String class that encapsulates the name
of and path to a WordprocessingML Word document that contains an
embedded binary Excel workbook.FileNotFoundException - Thrown if the file cannot be found
on the underlying file system.IOException - Thrown if a problem occurs in the underlying
file system.public void updateEmbeddedDoc()
throws OpenXML4JException,
IOException
OpenXML4JException - Rather
than use the specific classes (HSSF/XSSF) to handle the embedded
workbook this method uses those defined in the SS stream. As
a result, it might be the case that a SpreadsheetML file is
opened for processing, throwing this exception if that file is
invalid.IOException - Thrown if a problem occurs in the underlying
file system.public void checkUpdatedDoc()
throws OpenXML4JException,
IOException
Note that execution will not continue up to the assertion as the embedded workbook is now corrupted and causes an IllegalArgumentException with the following message
java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
to be thrown when the WorkbookFactory.createWorkbook(InputStream) method is executed.
OpenXML4JException - Rather
than use the specific classes (HSSF/XSSF) to handle the embedded
workbook this method uses those defined in the SS stream. As
a result, it might be the case that a SpreadsheetML file is
opened for processing, throwing this exception if that file is
invalid.IOException - Thrown if a problem occurs in the underlying
file system.public static void main(String[] args) throws IOException, OpenXML4JException
IOExceptionOpenXML4JException