Search code examples
javaxmlopendocumentodsjopendocument

JOpenDocument: problems with blank rows and cells


I have a problem when I parse .ods file with JOpenDocument . There are three rows and four columns in my file, but when I parse this file I get 1024 columns and too many rows. There are many blank cells.
I opened this .ods file like xml and it didn't have many lines.
And I couldn't find method for check empty cell in JOpenDocument API.

Here is my code where I create row with data:

ArrayList rowData = new ArrayList();
int countCol = sheet.getColumnCount();

for (int i = 0; i < countCol; i++) {
    rowData.add(getCellData(sheet.getName(), num, i));
}

How can I fix this problem? Maybe I have to change library?


Solution

  • jopendocument has a function for that: getUsedRange()

    Range range=sheet.getUsedRange();
    System.out.println("RANGE: "+range.toString());
    

    => RANGE: Feuille1.A1:.C8 (example)