首页 > 解决方案 > 我在java中使用jopendocument解析ods文件合并单元格有冲突吗?

问题描述

当我尝试使用 java 代码中的 jopentextformat 解析 ods 表时,会抛出一个异常,如下所示。请注意,第一个合并单元格的行和列获取合并单元格的第二个单元格引发以下错误的数据。请帮我解决一下这个。我将每个单元格转换为字符串,以便我可以比较和解析数据。在获取合并单元格(合并单元格的第二个单元格)时,会发生这种情况。

 public String getCellValueAt(int rowIndex, int columnIndex) {
     Sheet s;
     String cellVal;
     if (s.getCellAt(columnIndex, rowIndex).getValue() != null) {
     cellVal = s.getCellAt(columnIndex, rowIndex).getValue().toString();
        if(cellVal != null && cellVal != "") {
         cellVal = cellVal.trim();
        }
     }
        else {
            cellVal = " ";
        }
        return cellVal;
    }

//下面给出的异常

java.lang.IllegalArgumentException: invalid cell <table:covered-table-cell xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" />
at org.jopendocument.dom.spreadsheet.Row.getValidCellAt(Unknown Source) ~[jOpenDocument-1.3.jar:2.6.9]
at org.jopendocument.dom.spreadsheet.Row.getMutableCellAt(Unknown Source) ~[jOpenDocument-1.3.jar:2.6.9]
at org.jopendocument.dom.spreadsheet.Table.getCellAt(Unknown Source) ~[jOpenDocument-1.3.jar:2.6.9]

标签: javaparsingodsjopendocument

解决方案


推荐阅读