Class StreamRow
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 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) and the last column is
16383 (XFD); a column past it makes commit() throw
AxyraIoException. Setting the same column
twice keeps the last value. The add* methods write at the column
after the last one set, starting at column 0.
A style argument is an index returned by
StreamWorkbook.addStyle(io.keikai.axyra.sheets.io.StreamStyle); 0 is the default style. The index is not
checked: an index that addStyle did not return writes an invalid
style reference into the file. Overloads without style use 0.
A negative column throws IllegalArgumentException.
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; same assetNumber(next, value).addNumber(double value, int style) Appends a number with a style index at the next column.Appends text at the next column;nullwrites a blank.Appends text with a style index at the next column;nullwrites a styled blank.voidcommit()Writes the row to the file.setBlank(int column, int style) Sets a blank at 0-basedcolumnthat carries a style index.setBoolean(int column, boolean value) Sets TRUE or FALSE at 0-basedcolumnwith the default style.setBoolean(int column, boolean value, int style) Sets TRUE or FALSE at 0-basedcolumnwith a style index.Sets a date at 0-basedcolumn.setDateTime(int column, LocalDateTime value, int style) Sets a date-time at 0-basedcolumn; the time of day becomes the fractional part of the serial.setFormula(int column, String formula) Sets a formula at 0-basedcolumn, e.g.setFormula(int column, String formula, double cachedValue, int style) Sets a formula plus the cached numeric result that readers show before they recalculate.setFormula(int column, String formula, int style) Sets a formula at 0-basedcolumnwith a style index, without a cached result.setNumber(int column, double value) Sets a number at 0-basedcolumnwith the default style; seesetNumber(int, double, int).setNumber(int column, double value, int style) Sets a number at 0-basedcolumn(0-16383) with a style index fromStreamWorkbook.addStyle(io.keikai.axyra.sheets.io.StreamStyle).Sets text at 0-basedcolumn.Sets text at 0-basedcolumnwith a style index.skip()Leaves the next column empty and moves past it; nothing is written for it.
-
Method Details
-
addNumber
Appends a number at the next column; same assetNumber(next, value). -
addNumber
Appends a number with a style index at the next column. -
addText
Appends text at the next column;nullwrites a blank. -
addText
Appends text with a style index at the next column;nullwrites a styled blank. -
addBoolean
Appends a boolean at the next column. -
addDate
Appends a date at the next column;stylemust carry a date format. SeesetDate(int, LocalDate, int)for the serial rules. -
skip
Leaves the next column empty and moves past it; nothing is written for it. -
setNumber
Sets a number at 0-basedcolumnwith the default style; seesetNumber(int, double, int). -
setNumber
Sets a number at 0-basedcolumn(0-16383) with a style index fromStreamWorkbook.addStyle(io.keikai.axyra.sheets.io.StreamStyle). NaN and infinity are written as 0.- Parameters:
column- the 0-based columnvalue- the numberstyle- the style index; 0 is the default style- Returns:
- this row
- Throws:
IllegalArgumentException- ifcolumnis negative
-
setText
Sets text at 0-basedcolumn. Anullvalue writes nothing visible: an unstyled blank. -
setText
Sets text at 0-basedcolumnwith a style index. The text is stored inline in the cell, not in a shared string table.- Parameters:
column- the 0-based columnvalue- the text;nullwrites a blank withstylestyle- the style index; 0 is the default style- Returns:
- this row
- Throws:
IllegalArgumentException- ifcolumnis negative
-
setBoolean
Sets TRUE or FALSE at 0-basedcolumnwith the default style. -
setBoolean
Sets TRUE or FALSE at 0-basedcolumnwith a style index. -
setFormula
Sets a formula at 0-basedcolumn, e.g."SUM(A1:A9)". A leading=is accepted and removed. The formula is written as given and not checked.No cached result is written, so Excel shows 0 until it recalculates. Use
setFormula(int, String, double, int)when the value is known, as it usually is for a report generator.- Parameters:
column- the 0-based columnformula- the formula in en-US syntax- Returns:
- this row
- Throws:
IllegalArgumentException- ifformulaisnullor empty, orcolumnis negative
-
setFormula
Sets a formula at 0-basedcolumnwith a style index, without a cached result. A leading=is accepted and removed.- Parameters:
column- the 0-based columnformula- the formula in en-US syntaxstyle- the style index; 0 is the default style- Returns:
- this row
- Throws:
IllegalArgumentException- ifformulaisnullor empty, orcolumnis negative
-
setFormula
Sets a formula plus the cached numeric result that readers show before they recalculate. A leading=is accepted and removed.- Parameters:
column- the 0-based columnformula- the formula in en-US syntaxcachedValue- the result to store; NaN and infinity are written as 0style- the style index; 0 is the default style- Returns:
- this row
- Throws:
IllegalArgumentException- ifformulaisnullor empty, orcolumnis negative
-
setBlank
Sets a blank at 0-basedcolumnthat carries a style index. A blank with style 0 is not written at all. -
setDate
Sets a date at 0-basedcolumn. 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").The serial counts days from 1899-12-30 (the 1900 date system). Excel counts a 29 February 1900 that did not exist, so a date before 1900-03-01 shows one day later in Excel.
- Parameters:
column- the 0-based columnvalue- the date;nullwrites a blank withstylestyle- a style index whose number format is a date format- Returns:
- this row
- Throws:
IllegalArgumentException- ifcolumnis negative
-
setDateTime
Sets a date-time at 0-basedcolumn; the time of day becomes the fractional part of the serial. The date rules ofsetDate(int, LocalDate, int)apply.- Parameters:
column- the 0-based columnvalue- the date-time;nullwrites a blank withstylestyle- a style index whose number format shows a date or time- Returns:
- this row
- Throws:
IllegalArgumentException- ifcolumnis negative
-
commit
public void commit()Writes the row to the file. CallStreamWorkbook.row(int)for the next row; committing the same row twice throws.- Throws:
AxyraIoException- if the row index is not above the previous committed row, is 1,048,576 or above, a column is past 16383, or the file cannot be writtenIllegalStateException- if the writer is closed
-