spring-projects / spring-batch-extensions

Spring Batch Extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PoiSheet reads number of columns always from the first row

dusiema opened this issue · comments

commented

PoiSheet always reads the number of columns from the first row.

Especially when a RowNumberColumnNameExtractor is defined (with the headerRowNumber attribute set) it would make sense to read the number of columns from the row that has the header.

And maybe the default should be to read the number of columns for the current row that is processed.

@mdeinum What do you think?

Well the assumption is/was that when using a header you should always have the same amount of columns for all the rows. But maybe we should take a different approach on this and differentiate between using a header and not using a header. (Maybe even add some validation).

Agree on using the number of rows from the row that actually contains the header, I guess that was an omission when creating/refactoring this class.

Ofcourse pull requests are welcomed :).

commented

I looked into this again today.
But I am not sure on how to implement this.
I would like to only read the number of columns from the header row if a RowNumberColumnNameExtractor was set.
But the number of columns is read from the Sheet and the sheet does not know about the column name extractor because it is set on the AbstractExcelItemReader.

Should I just add a property like headerRowNumber on the AbstractExcelItemReader and the propagade it through to the Sheets getNumberOfColumns() ?

I did a fix for this, but that was still on my computer which got stolen yesterday :(.

The sheet should always use the column count of the row it is reading.