[
https://issues.apache.org/jira/browse/ODFTOOLKIT-104?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Florian Hopf closed ODFTOOLKIT-104.
-----------------------------------
Resolution: Fixed
> Create new spreadsheet, save it, load it, add a sheet, save it, then load it
> causes failure
> -------------------------------------------------------------------------------------------
>
> Key: ODFTOOLKIT-104
> URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-104
> Project: ODF Toolkit
> Issue Type: Bug
> Components: java
> Affects Versions: odfdom-0.8.5
> Environment: Operating System: Linux
> Platform: PC
> Reporter: datanucleus
> Priority: Critical
> Fix For: 0.5-incubating
>
> Attachments: ASF.LICENSE.NOT.GRANTED--bug173-closedocument.patch,
> ASF.LICENSE.NOT.GRANTED--odf_load.zip
>
>
> Created an attachment (id=257)
> Test app demonstrating the problem
> Very basic test of creating a new spreadsheet, saving it, then loading it and
> adding a new sheet with 2 columns, then saving it, and when loaded again it
> gives
> java.lang.IllegalArgumentException: Document contains incorrect ODF Mediatype
> 'null'
> at
> org.odftoolkit.odfdom.doc.OdfDocument.loadDocument(OdfDocument.java:356)
> at
> org.odftoolkit.odfdom.doc.OdfDocument.loadDocument(OdfDocument.java:344)
> at org.datanucleus.test.Main.main(Main.java:51)
> Such things never happened with 0.6.16. Sample app attached, and is as below.
> This was reported previously via the forum/mailing list and issue 106 got
> raised, but that hasn't addressed this basic problem.
> If there is some missing step in the provided app (that makes it work) then
> please let me know, but the documentation and examples for creating
> spreadsheets seem lacking.
> OdfDocument doc = null;
> String filename = "test.ods";
> File file = new File(filename);
> System.out.println(">> file=" + file);
> if (!file.exists())
> {
> // ODF spreadsheet doesn't exist, so create
> System.out.println(">> OdfDocument.newSpreadsheetDocument()");
> doc = OdfSpreadsheetDocument.newSpreadsheetDocument();
> System.out.println(">> OdfDocument.save(" + file + ")");
> doc.save(file);
> }
> // Load the document
> System.out.println(">> OdfDocument.loadDocument(" + file + ")");
> doc = OdfDocument.loadDocument(file);
> // Add the table and its columns
> OdfTable table = OdfTable.newTable(doc);
> String sheetName = "FirstSheet";
> table.setTableName(sheetName);
> int numCols = 2;
> for (int i=0;i<numCols;i++)
> {
> OdfTableColumn col = table.appendColumn();
> }
> // Save the document
> System.out.println(">> OdfDocument.save(" + file + ")");
> doc.save(file);
> // Load the document
> System.out.println(">> OdfDocument.loadDocument(" + file + ")");
> doc = OdfDocument.loadDocument(file);
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira