Package io.keikai.axyra.sheets.io
Class StreamRow
java.lang.Object
io.keikai.axyra.sheets.io.StreamRow
A row under construction for
StreamWorkbook.
Obtained from StreamWorkbook.row(int), filled with set* /
add* calls, and committed with commit(). The same instance
is handed back for every row of a workbook and its buffers are reused, so
writing ten million rows allocates the buffers once — that reuse is what
keeps the Java side's memory as flat as the engine's.
Cells may be set in any column order; only the columns actually set are
written. Columns are 0-based (0 is column A).
try (StreamWorkbook wb = StreamWorkbook.create(path)) {
int bold = wb.addStyle(StreamStyle.defaults().withBold());
wb.startSheet("Report");
wb.row(0).addText("Id", bold).addText("Name", bold).commit();
for (int r = 1; r <= 1_000_000; r++) {
wb.row(r).addNumber(r).addText("Customer " + r).commit();
}
}
-
Method Summary
Modifier and TypeMethodDescriptionaddBoolean(boolean value) Appends a boolean at the next column.Appends a date at the next column;stylemust carry a date format.addNumber(double value) Appends a number at the next column.addNumber(double value, int style) Appends a number with a style at the next column.Appends text at the next column.Appends text with a style at the next column.voidcommit()Writes the row and invalidates this builder until the nextrow().setBlank(int column, int style) Sets a styled blank atcolumn— worth writing only for the style.setBoolean(int column, boolean value) Sets a boolean atcolumn.setBoolean(int column, boolean value, int style) Sets a boolean with a style atcolumn.Sets a date atcolumn.setDateTime(int column, LocalDateTime value, int style) Sets a date-time atcolumn; the time becomes the fractional part.setFormula(int column, String formula) Sets a formula atcolumn, without the leading=.setFormula(int column, String formula, double cachedValue, int style) Sets a formula plus the cached result Excel shows before recalculating.setFormula(int column, String formula, int style) Sets a formula with a style atcolumn.setNumber(int column, double value) Sets a number atcolumn.setNumber(int column, double value, int style) Sets a number with a style atcolumn.Sets text atcolumn.Sets text with a style atcolumn.skip()Appends a blank at the next column, advancing past it.
-
Method Details
-
addNumber
Appends a number at the next column. -
addNumber
Appends a number with a style at the next column. -
addText
Appends text at the next column. -
addText
Appends text with a style at the next column. -
addBoolean
Appends a boolean at the next column. -
addDate
Appends a date at the next column;stylemust carry a date format. -
skip
Appends a blank at the next column, advancing past it. -
setNumber
Sets a number atcolumn. -
setNumber
Sets a number with a style atcolumn. -
setText
Sets text atcolumn. Anullvalue writes a blank. -
setText
Sets text with a style atcolumn. Anullvalue writes a blank. -
setBoolean
Sets a boolean atcolumn. -
setBoolean
Sets a boolean with a style atcolumn. -
setFormula
Sets a formula atcolumn, without the leading=.No cached result is written, so Excel shows 0 until it recalculates. Supply
setFormula(int, String, double, int)when the value is known — that is what a report generator normally has. -
setFormula
Sets a formula with a style atcolumn. -
setFormula
Sets a formula plus the cached result Excel shows before recalculating. -
setBlank
Sets a styled blank atcolumn— worth writing only for the style. -
setDate
Sets a date atcolumn. Excel has no date type: the cell holds a serial number andstylemust carry a date number format, e.g.StreamStyle.defaults().withNumberFormat("yyyy-mm-dd"). -
setDateTime
Sets a date-time atcolumn; the time becomes the fractional part. -
commit
public void commit()Writes the row and invalidates this builder until the nextrow().
-