[
https://issues.apache.org/jira/browse/ODFTOOLKIT-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Svante Schubert closed ODFTOOLKIT-106.
--------------------------------------
Resolution: Fixed
Assignee: (was: Svante Schubert)
ODF does not allow empty tables/spreadsheets without column/row/cell, see
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-schema.rng
and
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415586_253892949
If there should be another default number as a single cell in a table, we
should discuss this on the list. As the DOC API has been deprecated in favor of
the Simple API this issue is kind of outdated and will be closed for now.
> OdfTable.removeColumnsByIndex gives "java.lang.IllegalArgumentException:
> index should be nonnegative integer"
> -------------------------------------------------------------------------------------------------------------
>
> Key: ODFTOOLKIT-106
> URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-106
> Project: ODF Toolkit
> Issue Type: Bug
> Components: java
> Affects Versions: 0.8.5
> Environment: Operating System: Linux
> Platform: PC
> Reporter: datanucleus
> Priority: Critical
> Fix For: 0.8.7
>
> Attachments: table-column-autogeneration-test.patch
>
>
> I created a new Spreadsheet document. I then deleted all tables that had been
> added to it. I then created a new table, and it started with 2 rows and 5
> columns for some reason. I decided to delete them. Attempted deletion of the
> columns gave the error
> OdfDocument doc = null;
> String filename = "test.ods";
> File file = new File(filename);
> if (!file.exists())
> {
> // ODF spreadsheet doesn't exist, so create
> System.out.println(">> OdfDocument.newSpreadsheetDocument()");
> doc = OdfSpreadsheetDocument.newSpreadsheetDocument();
> // Delete any tables that ODFDOM created for us
> List<OdfTable> tables = new ArrayList(doc.getTableList());
> System.out.println(">> numtables=" + tables.size());
> Iterator<OdfTable> tableIter = tables.iterator();
> while (tableIter.hasNext())
> {
> OdfTable tbl = tableIter.next();
> tbl.remove();
> System.out.println(">> table=" + tbl.getTableName());
> }
> System.out.println(">> numtables(after)=" +
> doc.getTableList().size());
> 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);
> // Delete any columns that ODFDOM created for us
> System.out.println(">> numcols=" + table.getColumnCount());
> System.out.println(">> calling table.removeColumnsByIndex(0, " +
> table.getColumnCount() + ")");
> table.removeColumnsByIndex(0, table.getColumnCount());
> System.out.println(">> numcols(after)=" + table.getColumnCount());
> // Delete any rows that ODFDOM created for us
> System.out.println(">> numrows=" + table.getRowCount());
> table.removeRowsByIndex(0, table.getRowCount());
> System.out.println(">> numrows(after)=" + table.getRowCount());
> Output from this simple app is as follows
> >> file=test.ods
> >> OdfDocument.newSpreadsheetDocument()
> >> numtables=1
> >> table=Sheet1
> >> numtables(after)=0
> >> OdfDocument.save(test.ods)
> >> OdfDocument.loadDocument(test.ods)
> >> numcols=5
> >> calling table.removeColumnsByIndex(0, 5)
> java.lang.IllegalArgumentException: index should be nonnegative integer.
> at
> org.odftoolkit.odfdom.doc.table.OdfTableRow.getCellByIndex(OdfTableRow.java:274)
> at
> org.odftoolkit.odfdom.doc.table.OdfTableRow.removeCellByIndex(OdfTableRow.java:928)
> at
> org.odftoolkit.odfdom.doc.table.OdfTable.removeColumnsByIndex(OdfTable.java:1150)
> at org.datanucleus.test.Main.main(Main.java:54)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:290)
> at java.lang.Thread.run(Thread.java:619)
> So I'm calling OdfTable.removeColumnsByIndex(0, 5) and it thinks some input
> is negative. Why ?
> How do I get a simple OdfSpreadsheet without any creation artifacts (tables,
> rows, columns) ?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira