Class StreamRow

java.lang.Object
io.keikai.axyra.sheets.io.StreamRow

public final class StreamRow extends Object
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 Details

    • addNumber

      public StreamRow addNumber(double value)
      Appends a number at the next column.
    • addNumber

      public StreamRow addNumber(double value, int style)
      Appends a number with a style at the next column.
    • addText

      public StreamRow addText(String value)
      Appends text at the next column.
    • addText

      public StreamRow addText(String value, int style)
      Appends text with a style at the next column.
    • addBoolean

      public StreamRow addBoolean(boolean value)
      Appends a boolean at the next column.
    • addDate

      public StreamRow addDate(LocalDate value, int style)
      Appends a date at the next column; style must carry a date format.
    • skip

      public StreamRow skip()
      Appends a blank at the next column, advancing past it.
    • setNumber

      public StreamRow setNumber(int column, double value)
      Sets a number at column.
    • setNumber

      public StreamRow setNumber(int column, double value, int style)
      Sets a number with a style at column.
    • setText

      public StreamRow setText(int column, String value)
      Sets text at column. A null value writes a blank.
    • setText

      public StreamRow setText(int column, String value, int style)
      Sets text with a style at column. A null value writes a blank.
    • setBoolean

      public StreamRow setBoolean(int column, boolean value)
      Sets a boolean at column.
    • setBoolean

      public StreamRow setBoolean(int column, boolean value, int style)
      Sets a boolean with a style at column.
    • setFormula

      public StreamRow setFormula(int column, String formula)
      Sets a formula at column, 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

      public StreamRow setFormula(int column, String formula, int style)
      Sets a formula with a style at column.
    • setFormula

      public StreamRow setFormula(int column, String formula, double cachedValue, int style)
      Sets a formula plus the cached result Excel shows before recalculating.
    • setBlank

      public StreamRow setBlank(int column, int style)
      Sets a styled blank at column — worth writing only for the style.
    • setDate

      public StreamRow setDate(int column, LocalDate value, int style)
      Sets a date at column. Excel has no date type: the cell holds a serial number and style must carry a date number format, e.g. StreamStyle.defaults().withNumberFormat("yyyy-mm-dd").
    • setDateTime

      public StreamRow setDateTime(int column, LocalDateTime value, int style)
      Sets a date-time at column; the time becomes the fractional part.
    • commit

      public void commit()
      Writes the row and invalidates this builder until the next row().