Search before asking
Fesod version
main
JDK version
any
Operating system
Linux
Steps To Reproduce
List<List<Object>> data = Arrays.asList(
Arrays.asList("x", "y"),
Arrays.asList(" ", "\t"), // whitespace only
Arrays.asList("", ""), // empty strings
Arrays.asList(" ", "z"), // one blank cell next to data
Arrays.asList("p", "q"));
for (String ext : new String[] {".xlsx", ".xls", ".csv"}) {
File file = new File("blank" + ext);
FesodSheet.write(file).sheet().doWrite(data);
List<Map<Integer, String>> rows = FesodSheet.read(file).headRowNumber(0).sheet().doReadSync();
System.out.println(ext + " -> " + rows);
}
Current Behavior
The same content reads back differently depending only on the file extension:
| Row written |
.xlsx |
.xls |
.csv |
[" ", "\t"] |
skipped |
{0="", 1=""} |
{0=null, 1=null} |
["", ""] |
skipped |
{0="", 1=""} |
{0=null, 1=null} |
[" ", "z"] |
{0=null, 1="z"} |
{0="", 1="z"} |
{0=null, 1="z"} |
So XLSX returns 3 rows, while XLS and CSV return 5 rows. XLS also returns "" where the other formats return null, including in rows that have data.
With autoTrim(false), XLSX and XLS keep " " and "\t", but CSV still returns null for them.
Expected Behavior
All three formats should read the same content the same way. That means following the rule the XLSX reader already applies:
- A cell that is empty after
autoTrim/autoStrip is null.
- A row whose cells are all empty is an empty row, so it's skipped while
ignoreEmptyRow is true (the default).
Expected result for every format: [{0=x, 1=y}, {0=null, 1=z}, {0=p, 1=q}].
Anything else?
The fix is to call checkEmpty() in the two XLS label handlers and only mark the row as DATA when the cell isn't empty. In CSV, trim first, then check for empty, and mark the row EMPTY when every cell is empty.
This is a behaviour change: XLS users get null instead of "", and XLS/CSV users no longer receive all-blank rows unless they set ignoreEmptyRow(false).
Are you willing to submit a PR?
Search before asking
Fesod version
main
JDK version
any
Operating system
Linux
Steps To Reproduce
Current Behavior
The same content reads back differently depending only on the file extension:
.xlsx.xls.csv[" ", "\t"]{0="", 1=""}{0=null, 1=null}["", ""]{0="", 1=""}{0=null, 1=null}[" ", "z"]{0=null, 1="z"}{0="", 1="z"}{0=null, 1="z"}So XLSX returns 3 rows, while XLS and CSV return 5 rows. XLS also returns
""where the other formats returnnull, including in rows that have data.With
autoTrim(false), XLSX and XLS keep" "and"\t", but CSV still returnsnullfor them.Expected Behavior
All three formats should read the same content the same way. That means following the rule the XLSX reader already applies:
autoTrim/autoStripisnull.ignoreEmptyRowistrue(the default).Expected result for every format:
[{0=x, 1=y}, {0=null, 1=z}, {0=p, 1=q}].Anything else?
The fix is to call
checkEmpty()in the two XLS label handlers and only mark the row asDATAwhen the cell isn't empty. In CSV, trim first, then check for empty, and mark the rowEMPTYwhen every cell is empty.This is a behaviour change: XLS users get
nullinstead of"", and XLS/CSV users no longer receive all-blank rows unless they setignoreEmptyRow(false).Are you willing to submit a PR?