Class Cursor

java.lang.Object
io.github.dornol.excelkit.core.Cursor

public class Cursor extends Object
Tracks the current writing position during an export operation.

Used internally during streaming writing to track row position within the current sheet (or file) and the total number of rows processed globally (across multiple sheets). This allows support for sheet rollover, row-based formatting, and row-level indexing.

Since:
2025-07-19
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Cursor with row index and total count initialized to 0.
    Cursor(int baseRow)
    Creates a new Cursor starting from a specific row index.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the total number of processed rows, across all sheets.
    int
    Returns the current row index within the sheet.
    void
    Resets the current sheet's row index to the base row.
    void
    Increments the current row index in the current sheet by 1.
    void
    Increments the total number of processed rows (across all sheets) by 1.
    void
    setRowOfSheet(int row)
    Sets the current sheet's row index to the given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Cursor

      public Cursor()
      Creates a new Cursor with row index and total count initialized to 0.
    • Cursor

      public Cursor(int baseRow)
      Creates a new Cursor starting from a specific row index.
      Parameters:
      baseRow - The starting row index for each sheet (e.g., if there's a title)
  • Method Details

    • plusRow

      public void plusRow()
      Increments the current row index in the current sheet by 1.
    • initRow

      public void initRow()
      Resets the current sheet's row index to the base row. Typically called when a new sheet or file section is created.
    • setRowOfSheet

      public void setRowOfSheet(int row)
      Sets the current sheet's row index to the given value. Used when sheet preamble (beforeHeader) writes rows that shift the starting position.
      Parameters:
      row - the new row index
    • plusTotal

      public void plusTotal()
      Increments the total number of processed rows (across all sheets) by 1.
    • getRowOfSheet

      public int getRowOfSheet()
      Returns the current row index within the sheet.
      Returns:
      Row index in the current sheet (0-based)
    • getCurrentTotal

      public long getCurrentTotal()
      Returns the total number of processed rows, across all sheets.
      Returns:
      Total number of rows written