diff --git a/pom.xml b/pom.xml index 7a0ad26..49314e3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.miachm.sods SODS jar - 1.6.0 + 1.6.3 Simple ODS library A library for load/save ODS files in java. diff --git a/resources/features/bugs/cellContent.feature b/resources/features/bugs/cellContent.feature index a9894e0..aa1d1e9 100644 --- a/resources/features/bugs/cellContent.feature +++ b/resources/features/bugs/cellContent.feature @@ -23,3 +23,9 @@ Feature: Bugs related to invalid cell value content in SODS When the client creates a Range with 1,1,1,1 Then the formula of the range is "SUM(Operations!C:C)" + Scenario: Data tags returns a null value + When load a spreadsheet from the resource "emptyCell" + When get the first sheet + Then the cell values are: + | Test 1 | + | A | diff --git a/src/com/github/miachm/sods/OdsReader.java b/src/com/github/miachm/sods/OdsReader.java index 3bbd1a8..ddaa522 100644 --- a/src/com/github/miachm/sods/OdsReader.java +++ b/src/com/github/miachm/sods/OdsReader.java @@ -505,7 +505,6 @@ private void readCellText(XmlReaderInstance cellReader, Range range) { } else { s.append("\n"); } - // Add content of any contained text:span tags XmlReaderInstance spanElement = textElement.nextElement("text:s", XmlReaderInstance.CHARACTERS); diff --git a/src/com/github/miachm/sods/XmlReaderInstanceEventImpl.java b/src/com/github/miachm/sods/XmlReaderInstanceEventImpl.java index 9a305a7..f275b4e 100644 --- a/src/com/github/miachm/sods/XmlReaderInstanceEventImpl.java +++ b/src/com/github/miachm/sods/XmlReaderInstanceEventImpl.java @@ -5,6 +5,7 @@ import javax.xml.stream.XMLStreamReader; import java.util.HashMap; import java.util.Map; +import javax.xml.stream.XMLStreamConstants; class XmlReaderInstanceEventImpl implements XmlReaderInstance { private XMLStreamReader reader; @@ -24,7 +25,7 @@ class XmlReaderInstanceEventImpl implements XmlReaderInstance { String value = reader.getAttributeValue(i); atributes.put(name, value); } - else if (reader.isCharacters()) { + else if (isCharacters(reader)) { characters = reader.getText(); end = true; } @@ -58,7 +59,7 @@ else if (reader.isEndElement()) { return null; } } - else if (reader.isCharacters()) { + else if (isCharacters(reader)) { if (contains(names, CHARACTERS)) return new XmlReaderInstanceEventImpl(reader, CHARACTERS); } @@ -85,7 +86,11 @@ public String getContent() public String getTag() { return tag; } - + + private boolean isCharacters(XMLStreamReader reader) { + return reader.isCharacters() || reader.getEventType() == XMLStreamConstants.CDATA; + } + private String qNameToString(QName qName) { return qName.getPrefix() + ":" + qName.getLocalPart(); diff --git a/tests/steps/SpreadsheetCucumber.java b/tests/steps/SpreadsheetCucumber.java index 27e07d1..7388c1b 100644 --- a/tests/steps/SpreadsheetCucumber.java +++ b/tests/steps/SpreadsheetCucumber.java @@ -246,7 +246,7 @@ public void the_cell_values_are(DataTable dataTable) throws Throwable { Object[][] items = World.sheet.getDataRange().getValues(); for (int i = 0; i < table.size(); i++) { - for (int j = 0; j < table.size(); j++) { + for (int j = 0; j < table.get(i).size(); j++) { String value = table.get(i).get(j); if (value.equals("")) value = null;