Closed adn35350 closed 1 year ago
Thanks for your report! Please ensure you have provided enough info in order to recreate the issue, including the problematic ODS File.
This was really tricky one. The file is loaded correctly but at the end is corrupted by the "trim" feature.
Thanks for reporting, I can fix it now :)
Fixed in v1.5.2
Tanks for the fix. I think the problem is partially resolved.
When I read the same file, I obtain this result :
content | content | | content
content | content | content |
content | content | content |
First line and second lines are good but not the third.
Here is the good result that I obtain with the 1.4.0 version :
content | content | | content
content | content | content |
content | | |
Please tell me if you need more informations.
@adn35350 That's really weird. I created an unit test with your file and it's passing.
I am using sheet.getDataRange().getValues(). But maybe you are accesing the data in another way.
Can I ask you how are you testing this? A sample code would be great.
I'm using the same method sheet.getDataRange().getValues()
Here is the JUnit test that failed. You must to change the file path before testing.
@Test
void testReadContent() throws FileNotFoundException, IOException {
final String[] line1 = new String[] { "content", "content", null, "content" };
final String[] line2 = new String[] { "content", "content", "content", };
final String[] line3 = new String[] { "content", null, null, null };
final String[][] expected = new String[][] { line1, line2, line3 };
final File testFile = new File("/path/to/test-file.ods");
final SpreadSheet spreadsheet = new SpreadSheet(new FileInputStream(testFile));
final Sheet sheet = spreadsheet.getSheet(0);
final Range dataRange = sheet.getDataRange();
final Object[][] values = dataRange.getValues();
for (int i = 0; i < expected.length; i++) {
for (int j = 0; j < expected[i].length; j++) {
Assertions.assertEquals(expected[i][j], values[i][j], "Reading line " + (i + 1) + ", column " + (j + 1));
}
}
}
The result is :
org.opentest4j.AssertionFailedError: Reading line 3, column 2 ==> expected: <null> but was: <content>
Maybe the way I'm reading the ods file is bad ?
Apparently the test is valid when executing on another local machine.
I think it's not a problem with the library but on my computer.
It's very strange !
@adn35350 JDK versions?
openjdk 11.0.17 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode, sharing)
The test is passing for me in JDK8. But when I try in the Github CI with JDK11:
Failed tests: testReadContent(com.github.miachm.sods.SpreadSheetTest): content expected:
but was:<VALUE: 'content' != 'content'. Reading line 1, column 1>
https://github.com/miachm/SODS/pull/50
This is really weird...
I deleted all maven depencies in the .m2 directory. After doing this, test finally passes. Maybe it was just a refresh problem after branch checkout or after pom.xml update.
You can close this issue. Thanks for your help
Okay then, let´s close :)
Hello,
There is a problem when attempting to read lines which contain empty cells and non empty cells.
Here is the content of the ods file : :
The complete file
And this is the result of reading :
Please tell me if you need more informations.
Thanks