ODF Toolkit
  1. ODF Toolkit
  2. ODFTOOLKIT-104

Create new spreadsheet, save it, load it, add a sheet, save it, then load it causes failure

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: odfdom-0.8.5
    • Fix Version/s: 0.5-incubating
    • Component/s: java
    • Labels:
      None
    • Environment:
      Operating System: Linux
      Platform: PC

      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())

      { // 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);

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            datanucleus
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development