Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
odfdom-0.8.5
-
None
-
Operating System: Linux
Platform: PC
-
173
Description
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())
// 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++)
// 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);