On Thu, 6 Aug 2015, David North wrote:
On 16/05/15 11:02, Nick Burch wrote:
On Fri, 15 May 2015, David North wrote:
One change which we have in our local build of POI is the extraction of
super-interfaces to make streaming read of worksheets a bit nicer:
"CellEssence" is implemented by XSSFCell, HSSFCell and SXSSFCell:
"RowEssence" is similar and exposes CellEssences for that row.
Is the introduction of these interfaces something you'd consider
accepting a patch for? How do the names sound? Full list of methods
below for the record.
Thinking about it some more, with your details, I'd say it should probably
be
org.apache.poi.ss.usermodel.(something cell)
org.apache.poi.ss.usermodel.Cell extends (something cell)
org.apache.poi.hssf.usermodel.HSSFCell implements Cell
org.apache.poi.xssf.usermodel.XSSFCell implements Cell
org.apache.poi.xssf.eventusermodel.(something else cell) implements
(somthing cell)
The right combination or words for something and something else + cell I'm
still not quite sure on.
We use Base quite a bit, but I'm not sure if that's quite the right
naming?
For stripped-down cell etc interfaces, we also have the EvaluationCell /
EvaluationSheet / etc family of interfaces. I'd guess that quite a bit of
that will overlap between the core/base/essence cell and EvaluationCell,
so we should keep that in mind and try to re-use patterns / extend as
appropriate
This is quite low-level, though the pieces are all there. In order to
make it possible to transition some existing code written in terms of
Row and Cell across to streaming (while still being able to test it
against the non-streaming read), we invented CellEssence and RowEssence
as the minimal set of information from Row/Cell which is easy to
assemble during a streaming read using the above handler. So if we push
the interfaces upstream it would make sense to provide a handler, at
least as an example, showing how to create row and cell essences from a
streaming parse. Here's an extract from ours:
public void startRow(final int rowNum) {
_currentRow = new StreamedRowEssence(rowNum);
}
public void endRow() throws E {
essenceHandler.handleRow(_currentRow);
}
@Override
public void stringCell(final CellReference cellCoordinate, final
RichTextString text, final CellStyle style) {
StreamedCellEssence cell = addCell(cellCoordinate, style);
cell.setStringValue(text);
cell.setCellType(STCellType.STR);
}
Implementing Row/Cell on the objects created here would be a bit of a
lie as lots of methods would have to throw UnsupportedOperationException.
If we do this, I give it under 5 minutes until someone asks "how can I
read in with the streaming usermodel read then write out changes again
with SXSSF".
Given that, and give the logic already in SXSSFCell for going to/from raw
XML, would it be possible to have your XSSFSheetXMLHandler generate
SXSSFCells instead of a brand new cut-down cell object?
Also, as for UnsupportedOperationException, surely hitting one of those is
a challenge to the community to add in the missing functionality? ;-)
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]