Class SpreadsheetFile

java.lang.Object
ortus.boxlang.spreadsheet.SpreadsheetFile

public class SpreadsheetFile extends Object
A fluent API for managing spreadsheet files in BoxLang using Apache POI. This class provides a modern, chainable interface for creating, reading, and manipulating Excel files.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    ------------------------------------------------------------------------ Constants ------------------------------------------------------------------------
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor - initializes a new SpreadsheetFile instance Creates a new workbook with a default sheet named "Sheet1" and using the xlsx format
    SpreadsheetFile(boolean xmlFormat)
    Constructor with format specification
    SpreadsheetFile(boolean xmlFormat, String sheetName)
    Constructor with format specification and sheet name
  • Method Summary

    Modifier and Type
    Method
    Description
    addAutofilter(int startRow, int startColumn, int endRow, int endColumn)
    Adds autofilter to a range in the active sheet
    addFreezePane(int column, int row)
    Adds a freeze pane to the active sheet
    addFreezePane(int column, int row, int endColumn, int endRow)
    Adds a freeze pane to the active sheet with end boundaries
    addImage(String filepath, int row, int column)
    Adds an image to the active sheet at the specified cell position
    addImage(String filepath, int startRow, int startCol, int endRow, int endCol)
    Adds an image to the active sheet with custom anchor dimensions
    Adds print gridlines to the active sheet (gridlines will print)
    addRow(String values)
    Adds a new row with the specified data at the end of the active sheet
    addRow(String sheetName, ortus.boxlang.runtime.types.Array values)
    Adds a new row with the specified data at the end of the specified sheet
    addRow(ortus.boxlang.runtime.types.Array values)
    Adds a new row with the specified data at the end of the active sheet
    addRow(ortus.boxlang.runtime.types.Array values, int row, int column, boolean insert)
    Adds a new row with the specified data at the specified position in the active sheet
    addRows(ortus.boxlang.runtime.types.Array data)
    Sets all data for the active sheet from a 2D array We won't include column names by default, this means, row 1 of data will be skipped
    addRows(ortus.boxlang.runtime.types.Array data, boolean includeColumnNames)
    Sets all data for the active sheet from a 2D array
    addRows(ortus.boxlang.runtime.types.Array data, int row, int column, boolean insert, boolean includeColumnNames)
    Sets all data for the active sheet from a 2D array starting at specified row and column
    addRows(ortus.boxlang.runtime.types.Array data, int row, int column, boolean insert, boolean includeColumnNames, String sheetName)
    Sets all data for the active sheet from a 2D array starting at specified row and column
    addRows(ortus.boxlang.runtime.types.Array data, String sheetName)
    Sets all data for the active sheet from a 2D array We won't include column names by default, this means, row 1 of data will be skipped
    addRows(ortus.boxlang.runtime.types.Array data, String sheetName, boolean includeColumnNames)
    Sets all data for the active sheet from a 2D array We won't include column names by default, this means, row 1 of data will be skipped
    addSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow)
    Adds a split pane to the active sheet with default active pane (LOWER_RIGHT)
    addSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
    Adds a split pane to the active sheet
    autoCloseOnSave(boolean autoClose)
    Sets whether to auto close the workbook when saving
    autoSizeColumn(int column)
    Auto-sizes a specific column in the active sheet
    autoSizeColumn(String sheetName, int column)
    Auto-sizes a specific column in the specified sheet
    Auto-sizes all columns in the active sheet
    Auto-sizes all columns in the specified sheet
    clearCell(int row, int col)
    Clears the specified cell of all styles and values in the active sheet
    clearCellRange(int startRow, int startCol, int endRow, int endCol)
    Clears a range of cells of all styles and values in the active sheet
    clearSheet(String sheetName)
    Clears all data from the specified sheet
    void
    Closes the workbook and releases resources
    copySheet(String fromName, String toName)
    Copies a sheet with a new name Creates a complete copy of the source sheet including all data, formatting, and structure
    Creates a new sheet and makes it the active sheet
    createAndSelectSheet(String sheetName, boolean overwrite)
    Creates a new sheet and makes it the active sheet
    createSheet(String sheetName)
    Creates a new sheet with the specified name
    createSheet(String sheetName, boolean overwrite)
    Creates a new sheet with the specified name
    deleteColumn(int column)
    Deletes a column by clearing all cells in that column
    deleteColumn(String sheetName, int column)
    Deletes a column by clearing all cells in that column from the specified sheet
    deleteColumns(int startColumn, int endColumn)
    Deletes multiple columns by clearing all cells in those columns
    deleteColumns(String sheetName, int startColumn, int endColumn)
    Deletes multiple columns by clearing all cells in those columns from the specified sheet
    formatCell(int row, int col, ortus.boxlang.runtime.types.IStruct format)
    Formats a cell in the active sheet
    formatCell(String sheetName, int row, int col, ortus.boxlang.runtime.types.IStruct format)
    Formats a cell in the specified sheet
    formatCellRange(ortus.boxlang.runtime.types.IStruct format, int startRow, int startCol, int endRow, int endCol)
    Formats a range of cells in the active sheet with a single format struct
    formatColumn(int column, ortus.boxlang.runtime.types.IStruct format)
    Formats all cells in a single column in the active sheet
    formatColumn(String sheetName, int column, ortus.boxlang.runtime.types.IStruct format)
    Formats all cells in a single column in the specified sheet
    formatColumns(String sheetName, String columns, ortus.boxlang.runtime.types.IStruct format)
    Formats multiple columns in the specified sheet Column specification format: "1,3,5" or "1-5,7-10" or combinations
    formatColumns(String columns, ortus.boxlang.runtime.types.IStruct format)
    Formats multiple columns in the active sheet Column specification format: "1,3,5" or "1-5,7-10" or combinations
    formatRow(int row, ortus.boxlang.runtime.types.IStruct format)
    Formats all cells in a single row in the active sheet
    formatRow(String sheetName, int row, ortus.boxlang.runtime.types.IStruct format)
    Formats all cells in a single row in the specified sheet
    formatRows(String sheetName, String rows, ortus.boxlang.runtime.types.IStruct format)
    Formats multiple rows in the specified sheet Row specification format: "1,3,5" or "1-5,7-10" or combinations
    formatRows(String rows, ortus.boxlang.runtime.types.IStruct format)
    Formats multiple rows in the active sheet Row specification format: "1,3,5" or "1-5,7-10" or combinations
    fromArray(ortus.boxlang.runtime.types.Array data)
    Creates a new SpreadsheetFile from an array of structs The first struct's keys will be used as column headers in row 1 Each struct represents a data row
    Creates a new SpreadsheetFile from JSON string data The JSON should be an array of objects where each object represents a row The keys of the first object will be used as column headers
    fromQuery(ortus.boxlang.runtime.types.Query query)
    Creates a new SpreadsheetFile from query-like data (array of structs) Alias for fromArray() to match the fluent API pattern
    fromWorkbook(org.apache.poi.ss.usermodel.Workbook workbook)
    Creates a new SpreadsheetFile from an existing workbook
    ortus.boxlang.runtime.types.IStruct
    Gets the currently active/selected cell in the active sheet
    org.apache.poi.ss.usermodel.Sheet
    Gets the active sheet
    Gets the name of the active sheet
    ortus.boxlang.runtime.types.Array
    Gets all comments from the active sheet
    ortus.boxlang.runtime.types.Array
    Gets all data from the active sheet as a 2D array
    ortus.boxlang.runtime.types.Array
    getAllData(String sheetName)
    Gets all data from the specified sheet as a 2D array
    ortus.boxlang.runtime.types.Array
    Gets all cell formulas from the active sheet as a 2D array with each value being a struct with the following keys: - formula : The cell formula as a string - row : The row number (1-based) - column : The column number (1-based)
    boolean
    Gets whether formulas automatically calculate
    getCellAddress(int row, int column)
    Gets the cell address string for a given row and column (e.g., "A1", "B5")
    ortus.boxlang.runtime.types.IStruct
    getCellComment(int row, int col)
    Gets a comment from a cell in the active sheet
    ortus.boxlang.runtime.types.IStruct
    getCellFormat(int row, int col)
    Gets the formatting information of the specified cell in the active sheet
    getCellFormula(int row, int col)
    Gets cell formula from the active sheet and a specified cell
    ortus.boxlang.runtime.types.IStruct
    getCellHyperlink(int row, int column)
    Gets the hyperlink from a cell in the active sheet
    getCellType(int row, int col)
    Gets the Excel cell type of the specified cell in the active sheet
    getCellValue(int row, int col)
    Gets a cell value at the specified row and column in the active sheet
    getCellValue(String sheetName, int row, int col)
    Gets a cell value at the specified row and column in the specified sheet
    int
    Gets the number of columns in the active sheet
    int
    Gets the number of columns in the specified sheet
    ortus.boxlang.runtime.types.Array
    Gets the column names for the active sheet.
    ortus.boxlang.runtime.types.Array
    Gets the column names for the specified sheet.
    ortus.boxlang.runtime.types.Array
    Gets the column types for the active sheet by analyzing the data in the second row (assuming first row is headers).
    ortus.boxlang.runtime.types.Array
    Gets the column types for the specified sheet by analyzing the data in the second row (assuming first row is headers).
    double
    getColumnWidth(int column)
    Gets the width of a column in the active sheet (defaults to pixels).
    double
    getColumnWidth(int column, boolean returnWidthInPixels)
    Gets the width of a column in the active sheet.
    ortus.boxlang.runtime.types.Array
    Gets data from the active sheet as an array of structs (first row as headers)
    ortus.boxlang.runtime.types.Array
    Gets data from the specified sheet as an array of structs (first row as headers)
    int
    Gets the last row number with data in the active sheet.
    org.apache.poi.ss.usermodel.Sheet
    Get a sheet by name or create it if it doesn't exist
    Gets the file path
    Gets the print orientation of the active sheet.
    boolean
    Gets whether formulas will be recalculated when the file is opened
    int
    Gets the number of rows in the active sheet
    int
    getRowCount(String sheetName)
    Gets the number of rows in the specified sheet
    ortus.boxlang.runtime.types.Array
    getRowData(int row)
    Gets all cell values from a row
    ortus.boxlang.runtime.types.Array
    getRowData(String sheetName, int row)
    Gets all cell values from a row in the specified sheet
    org.apache.poi.ss.usermodel.Sheet
    getSheet(String sheetName)
    Get a sheet by name
    int
    Gets the number of sheets in the workbook
    ortus.boxlang.runtime.types.Array
    Gets all sheet names
    ortus.boxlang.runtime.types.IStruct
    Get all the sheet visibility information as a Struct
    org.apache.poi.ss.usermodel.Workbook
    Gets the underlying Apache POI workbook
    groupColumns(int startColumn, int endColumn)
    Groups columns together in the active sheet (expanded by default)
    groupColumns(int startColumn, int endColumn, Boolean isCollapsed)
    Groups columns together in the active sheet for outline/collapse functionality
    groupRows(int startRow, int endRow)
    Groups rows together in the active sheet (expanded by default)
    groupRows(int startRow, int endRow, Boolean isCollapsed)
    Groups rows together in the active sheet for outline/collapse functionality
    boolean
    hasSheet(String sheetName)
    Checks if a sheet exists
    hideColumn(int column)
    Hides a column on the active sheet (fluent API)
    hideRow(int row)
    Hides a row on the active sheet (fluent API)
    hideSheet(String sheetName)
    Hides a sheet from view
    ortus.boxlang.runtime.types.IStruct
    Returns properties of a spreadsheet as a struct.
    boolean
    Is auto close on save enabled
    boolean
    Gets whether the spreadsheet is in binary format (.xls)
    boolean
    Checks if the workbook has been closed
    boolean
    isColumnHidden(int column)
    Gets the hidden state of a column on the active sheet
    boolean
    Gets whether overwrite is enabled
    boolean
    isRowHidden(int row)
    Gets the hidden state of a row on the active sheet
    boolean
    Checks if the workbook is in XML format (.xlsx)
    load(String path)
    Loads a spreadsheet file from the specified path
    load(String path, String password)
    Loads a spreadsheet file from the specified path with optional password
    mergeCells(int startRow, int startColumn, int endRow, int endColumn)
    Merges cells in the active sheet
    moveSheet(int fromIndex, int toIndex)
    Moves a sheet to a new position by index
    moveSheet(String sheetName, int toIndex)
    Moves a sheet to a new position by name
    overwrite(boolean overwrite)
    Sets whether to overwrite existing files when saving
    process(String path, String sheetName, Consumer<ortus.boxlang.runtime.types.Array> rowConsumer)
    Stream rows from a specific sheet in a spreadsheet file on disk using true streaming.
    process(String path, Consumer<ortus.boxlang.runtime.types.Array> rowConsumer)
    Stream rows from a spreadsheet file on disk using true streaming (memory efficient).
    process(Consumer<ortus.boxlang.runtime.types.Array> rowConsumer)
    Stream rows from the currently-loaded workbook (this.workbook).
    Recalculates all formulas in the workbook
    removeColumnBreak(int column)
    Removes a page (column) break at the specified 1-based column index on the active sheet.
    Removes print gridlines from the active sheet (gridlines will not print)
    void
    removeRow(int rowIndex)
    Removes a row from the active sheet
    removeRowBreak(int row)
    Removes a page (row) break at the specified 1-based row index on the active sheet.
    removeSheet(int sheetNumber)
    Removes a sheet by number (1-based index)
    removeSheet(String sheetName)
    Removes a sheet by name
    renameSheet(String oldName, String newName)
    Renames an existing sheet
    Saves the spreadsheet to the currently loaded path
    save(String path)
    Saves the spreadsheet to the specified path
    save(String path, String password)
    Saves the spreadsheet to the specified path with password protection
    Saves the spreadsheet to the currently loaded path and closes the workbook
    Saves the spreadsheet to the currently loaded path and closes the workbook
    saveAndClose(String path, String password)
    Saves the spreadsheet to the specified path with password protection and closes the workbook
    selectSheet(int sheetIndex)
    Selects (activates) a sheet by index (1-based)
    selectSheet(String sheetName)
    Selects (activates) a sheet by name
    setActiveCell(int row, int col)
    Sets the active/selected cell in the active sheet
    setAutoCalculate(boolean autoCalculate)
    Sets whether formulas automatically calculate
    setCellComment(int row, int col, String comment)
    Sets a comment on a cell in the active sheet
    setCellComment(int row, int col, String comment, String author)
    Sets a comment on a cell in the active sheet with an author
    setCellComment(int row, int col, ortus.boxlang.runtime.types.IStruct commentStruct)
    Sets a comment on a cell in the active sheet from a struct with formatting options
    setCellFormula(int row, int col, String formula)
    Sets cell formula in the active sheet
    setCellHyperlink(int row, int column, String hyperlink)
    Sets a hyperlink on a cell in the active sheet (without a custom label)
    setCellHyperlink(int row, int column, String hyperlink, String label)
    Sets a hyperlink on a cell in the active sheet
    setCellRangeValue(Object value, int startRow, int startCol, int endRow, int endCol)
    Sets the same value to a range of cells in the active sheet
    setCellValue(int row, int col, Object value)
    Sets a cell value at the specified row and column in the active sheet
    setCellValue(String sheetName, int row, int col, Object value)
    Sets a cell value at the specified row and column in the specified sheet
    setColumnBreak(int column)
    Sets a page (column) break at the specified 1-based column index on the active sheet.
    setColumnHidden(int column, boolean hidden)
    Sets the hidden state of a column on the active sheet
    setColumnWidth(int column, double width)
    Sets the width of a column in the active sheet
    setFitToPage(boolean fitToPage, int pagesWide, int pagesHigh)
    Sets the fit-to-page print option for the active sheet
    setFooter(ortus.boxlang.runtime.types.IStruct footer)
    Sets the footer for the active sheet using a struct with optional keys: left, center, right
    setFooterImage(String alignment, String imagePath)
    Sets an image in the footer of the active sheet
    setHeader(ortus.boxlang.runtime.types.IStruct header)
    Sets the header for the active sheet using a struct with optional keys: left, center, right
    setHeaderImage(String alignment, String imagePath)
    Sets an image in the header of the active sheet
    setInfo(ortus.boxlang.runtime.types.IStruct properties)
    Sets document properties/metadata for the workbook (alias for addInfo)
    Sets the file path for this spreadsheet
    setRecalculateFormulasOnNextOpen(boolean recalculate)
    Sets whether formulas should be recalculated when the file is opened
    setRepeatingColumns(int startCol, int endCol)
    Sets columns to repeat on every printed page for the active sheet
    setRepeatingRows(int startRow, int endRow)
    Sets rows to repeat on every printed page for the active sheet
    setRowBreak(int row)
    Sets a page (row) break at the specified 1-based row index on the active sheet.
    setRowData(int row, ortus.boxlang.runtime.types.Array values)
    Sets multiple cell values from a row of data
    setRowData(String sheetName, int row, ortus.boxlang.runtime.types.Array values)
    Sets multiple cell values from a row of data in the specified sheet
    setRowHeight(int row, double height)
    Sets the height of a row in the active sheet
    setRowHidden(int row, boolean hidden)
    Sets the hidden state of a row on the active sheet
    Sets the print orientation for the active sheet
    shiftColumns(int start)
    Shifts columns left or right in the active sheet (single column, default shift right by 1)
    shiftColumns(int start, int n)
    Shifts columns left or right in the active sheet (single column with shift amount)
    shiftColumns(int start, int end, int n)
    Shifts columns left or right in the active sheet
    shiftRows(int start)
    Shifts rows up or down in the active sheet (single row, default shift down by 1)
    shiftRows(int start, int n)
    Shifts rows up or down in the active sheet (single row with shift amount)
    shiftRows(int start, int end, int n)
    Shifts rows up or down in the active sheet
    showColumn(int column)
    Shows a hidden column on the active sheet (fluent API)
    showRow(int row)
    Shows a hidden row on the active sheet (fluent API)
    ortus.boxlang.runtime.types.Array
    Converts the active sheet data to an array of structs (first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
    ortus.boxlang.runtime.types.Array
    toArray(String sheetName)
    Converts the specified sheet data to an array of structs (first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
    Converts the active sheet data to CSV format with default options Default options: comma delimiter, includes headers, CRLF line separator
    toCSV(String sheetName)
    Converts the specified sheet data to CSV format with default options
    toCSV(String sheetName, ortus.boxlang.runtime.types.IStruct options)
    Converts the specified sheet data to CSV format with custom options
    toCSV(ortus.boxlang.runtime.types.IStruct options)
    Converts the active sheet data to CSV format with custom options
    Converts the active sheet data to JSON string
    toJson(boolean pretty)
    Converts the active sheet data to JSON string
    toJson(String sheetName, boolean pretty)
    Converts the specified sheet data to JSON string
    ortus.boxlang.runtime.types.Array
    Converts the active sheet data to a 2D array matrix (including headers) Returns all rows including the header row as arrays
    ortus.boxlang.runtime.types.Array
    toMatrix(String sheetName)
    Converts the specified sheet data to a 2D array matrix (including headers) Returns all rows including the header row as arrays
    ortus.boxlang.runtime.types.Array
    Converts the active sheet data to query format (array of structs with first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
    ortus.boxlang.runtime.types.Array
    toQuery(String sheetName)
    Converts the specified sheet data to query format (array of structs with first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
    String representation of the spreadsheet file
    ungroupColumns(int startColumn, int endColumn)
    Ungroups columns in the active sheet
    ungroupRows(int startRow, int endRow)
    Ungroups rows in the active sheet
    unhideSheet(String sheetName)
    Unhides a sheet to make it visible
    xls()
    Creates a new SpreadsheetFile with .xls format
    Creates a new SpreadsheetFile with .xlsx format

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_SHEET_NAME

      public static final String DEFAULT_SHEET_NAME
      ------------------------------------------------------------------------ Constants ------------------------------------------------------------------------
      See Also:
  • Constructor Details

    • SpreadsheetFile

      public SpreadsheetFile()
      Constructor - initializes a new SpreadsheetFile instance Creates a new workbook with a default sheet named "Sheet1" and using the xlsx format
    • SpreadsheetFile

      public SpreadsheetFile(boolean xmlFormat)
      Constructor with format specification
      Parameters:
      xmlFormat - True for .xlsx format, false for .xls format
    • SpreadsheetFile

      public SpreadsheetFile(boolean xmlFormat, String sheetName)
      Constructor with format specification and sheet name
      Parameters:
      xmlFormat - True for .xlsx format, false for .xls format
      sheetName - The name of the initial sheet
  • Method Details

    • fromWorkbook

      public static SpreadsheetFile fromWorkbook(org.apache.poi.ss.usermodel.Workbook workbook)
      Creates a new SpreadsheetFile from an existing workbook
      Parameters:
      workbook - The Apache POI workbook
      Returns:
      A new SpreadsheetFile instance
    • xlsx

      public static SpreadsheetFile xlsx()
      Creates a new SpreadsheetFile with .xlsx format
      Returns:
      A new SpreadsheetFile instance in XML format
    • xls

      public static SpreadsheetFile xls()
      Creates a new SpreadsheetFile with .xls format
      Returns:
      A new SpreadsheetFile instance in binary format
    • fromJson

      public static SpreadsheetFile fromJson(String json)
      Creates a new SpreadsheetFile from JSON string data The JSON should be an array of objects where each object represents a row The keys of the first object will be used as column headers
      Parameters:
      json - JSON string containing array of objects
      Returns:
      A new SpreadsheetFile instance populated with the data
    • fromArray

      public static SpreadsheetFile fromArray(ortus.boxlang.runtime.types.Array data)
      Creates a new SpreadsheetFile from an array of structs The first struct's keys will be used as column headers in row 1 Each struct represents a data row
      Parameters:
      data - Array of structs where each struct is a row
      Returns:
      A new SpreadsheetFile instance populated with the data
    • fromQuery

      public static SpreadsheetFile fromQuery(ortus.boxlang.runtime.types.Query query)
      Creates a new SpreadsheetFile from query-like data (array of structs) Alias for fromArray() to match the fluent API pattern
      Parameters:
      query - A BoxLang query
      Returns:
      A new SpreadsheetFile instance populated with the data
    • load

      public SpreadsheetFile load(String path)
      Loads a spreadsheet file from the specified path
      Parameters:
      path - A fully qualified path to a spreadsheet file
      Returns:
      This SpreadsheetFile instance for method chaining
    • load

      public SpreadsheetFile load(String path, String password)
      Loads a spreadsheet file from the specified path with optional password
      Parameters:
      path - A fully qualified path to a spreadsheet file
      password - Optional password for encrypted files
      Returns:
      This SpreadsheetFile instance for method chaining
    • save

      public SpreadsheetFile save()
      Saves the spreadsheet to the currently loaded path
      Returns:
      This SpreadsheetFile instance for method chaining
    • saveAndClose

      public SpreadsheetFile saveAndClose()
      Saves the spreadsheet to the currently loaded path and closes the workbook
      Returns:
      This SpreadsheetFile instance for method chaining
    • save

      public SpreadsheetFile save(String path)
      Saves the spreadsheet to the specified path
      Parameters:
      path - The path to save the file
      Returns:
      This SpreadsheetFile instance for method chaining
    • saveAndClose

      public SpreadsheetFile saveAndClose(String path)
      Saves the spreadsheet to the currently loaded path and closes the workbook
      Parameters:
      path - The path to save the file
      Returns:
      This SpreadsheetFile instance for method chaining
    • save

      public SpreadsheetFile save(String path, String password)
      Saves the spreadsheet to the specified path with password protection
      Parameters:
      path - The path to save the file
      password - The password to protect the file with
      Returns:
      This SpreadsheetFile instance for method chaining
    • saveAndClose

      public SpreadsheetFile saveAndClose(String path, String password)
      Saves the spreadsheet to the specified path with password protection and closes the workbook
      Parameters:
      path - The path to save the file
      password - The password to protect the file with
      Returns:
      This SpreadsheetFile instance for method chaining
    • overwrite

      public SpreadsheetFile overwrite(boolean overwrite)
      Sets whether to overwrite existing files when saving
      Parameters:
      overwrite - True to overwrite existing files, false otherwise
      Returns:
      This SpreadsheetFile instance for method chaining
    • autoCloseOnSave

      public SpreadsheetFile autoCloseOnSave(boolean autoClose)
      Sets whether to auto close the workbook when saving
      Parameters:
      autoClose - True to auto close on save, false otherwise
      Returns:
      This SpreadsheetFile instance for method chaining
    • isAutoCloseOnSave

      public boolean isAutoCloseOnSave()
      Is auto close on save enabled
    • setPath

      public SpreadsheetFile setPath(String path)
      Sets the file path for this spreadsheet
      Parameters:
      path - The file path
      Returns:
      This SpreadsheetFile instance for method chaining
    • createSheet

      public SpreadsheetFile createSheet(String sheetName, boolean overwrite)
      Creates a new sheet with the specified name
      Parameters:
      sheetName - The name of the new sheet
      overwrite - Whether to overwrite an existing sheet with the same name
      Returns:
      This SpreadsheetFile instance for method chaining
    • createSheet

      public SpreadsheetFile createSheet(String sheetName)
      Creates a new sheet with the specified name
      Parameters:
      sheetName - The name of the new sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • createAndSelectSheet

      public SpreadsheetFile createAndSelectSheet(String sheetName)
      Creates a new sheet and makes it the active sheet
      Parameters:
      sheetName - The name of the new sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • createAndSelectSheet

      public SpreadsheetFile createAndSelectSheet(String sheetName, boolean overwrite)
      Creates a new sheet and makes it the active sheet
      Parameters:
      sheetName - The name of the new sheet
      overwrite - Whether to overwrite an existing sheet with the same name
      Returns:
      This SpreadsheetFile instance for method chaining
    • selectSheet

      public SpreadsheetFile selectSheet(String sheetName)
      Selects (activates) a sheet by name
      Parameters:
      sheetName - The name of the sheet to activate
      Returns:
      This SpreadsheetFile instance for method chaining
    • selectSheet

      public SpreadsheetFile selectSheet(int sheetIndex)
      Selects (activates) a sheet by index (1-based)
      Parameters:
      sheetIndex - The index of the sheet to activate (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • removeSheet

      public SpreadsheetFile removeSheet(String sheetName)
      Removes a sheet by name
      Parameters:
      sheetName - The name of the sheet to remove
      Returns:
      This SpreadsheetFile instance for method chaining
    • removeSheet

      public SpreadsheetFile removeSheet(int sheetNumber)
      Removes a sheet by number (1-based index)
      Parameters:
      sheetNumber - The sheet number to remove (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • renameSheet

      public SpreadsheetFile renameSheet(String oldName, String newName)
      Renames an existing sheet
      Parameters:
      oldName - The current name of the sheet
      newName - The new name for the sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • copySheet

      public SpreadsheetFile copySheet(String fromName, String toName)
      Copies a sheet with a new name Creates a complete copy of the source sheet including all data, formatting, and structure
      Parameters:
      fromName - The name of the sheet to copy from
      toName - The name of the new sheet
      Returns:
      This SpreadsheetFile instance for method chaining
      Throws:
      ortus.boxlang.runtime.types.exceptions.BoxRuntimeException - if the source sheet doesn't exist or target sheet already exists
    • hideSheet

      public SpreadsheetFile hideSheet(String sheetName)
      Hides a sheet from view
      Parameters:
      sheetName - The name of the sheet to hide
      Returns:
      This SpreadsheetFile instance for method chaining
    • unhideSheet

      public SpreadsheetFile unhideSheet(String sheetName)
      Unhides a sheet to make it visible
      Parameters:
      sheetName - The name of the sheet to unhide
      Returns:
      This SpreadsheetFile instance for method chaining
    • moveSheet

      public SpreadsheetFile moveSheet(int fromIndex, int toIndex)
      Moves a sheet to a new position by index
      Parameters:
      fromIndex - The current sheet index (0-based)
      toIndex - The target sheet index (0-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • moveSheet

      public SpreadsheetFile moveSheet(String sheetName, int toIndex)
      Moves a sheet to a new position by name
      Parameters:
      sheetName - The name of the sheet to move
      toIndex - The target sheet index (0-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getCellAddress

      public String getCellAddress(int row, int column)
      Gets the cell address string for a given row and column (e.g., "A1", "B5")
      Parameters:
      row - The row number (1-based)
      column - The column number (1-based)
      Returns:
      The cell address string
    • info

      public ortus.boxlang.runtime.types.IStruct info()
      Returns properties of a spreadsheet as a struct.
      Returns:
      A struct containing sheet properties
    • recalculateAllFormulas

      public SpreadsheetFile recalculateAllFormulas()
      Recalculates all formulas in the workbook
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellValue

      public SpreadsheetFile setCellValue(int row, int col, Object value)
      Sets a cell value at the specified row and column in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      value - The value to set
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellValue

      public SpreadsheetFile setCellValue(String sheetName, int row, int col, Object value)
      Sets a cell value at the specified row and column in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      row - The row number (1-based)
      col - The column number (1-based)
      value - The value to set
      Returns:
      This SpreadsheetFile instance for method chaining
    • getCellValue

      public Object getCellValue(int row, int col)
      Gets a cell value at the specified row and column in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      The cell value
    • getCellValue

      public Object getCellValue(String sheetName, int row, int col)
      Gets a cell value at the specified row and column in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      The cell value
    • formatCell

      public SpreadsheetFile formatCell(int row, int col, ortus.boxlang.runtime.types.IStruct format)
      Formats a cell in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatCell

      public SpreadsheetFile formatCell(String sheetName, int row, int col, ortus.boxlang.runtime.types.IStruct format)
      Formats a cell in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      row - The row number (1-based)
      col - The column number (1-based)
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatRow

      public SpreadsheetFile formatRow(int row, ortus.boxlang.runtime.types.IStruct format)
      Formats all cells in a single row in the active sheet
      Parameters:
      row - The row number (1-based)
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatRow

      public SpreadsheetFile formatRow(String sheetName, int row, ortus.boxlang.runtime.types.IStruct format)
      Formats all cells in a single row in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      row - The row number (1-based)
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatRows

      public SpreadsheetFile formatRows(String rows, ortus.boxlang.runtime.types.IStruct format)
      Formats multiple rows in the active sheet Row specification format: "1,3,5" or "1-5,7-10" or combinations
      Parameters:
      rows - A string specifying which rows to format
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatRows

      public SpreadsheetFile formatRows(String sheetName, String rows, ortus.boxlang.runtime.types.IStruct format)
      Formats multiple rows in the specified sheet Row specification format: "1,3,5" or "1-5,7-10" or combinations
      Parameters:
      sheetName - The name of the sheet
      rows - A string specifying which rows to format
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatColumn

      public SpreadsheetFile formatColumn(int column, ortus.boxlang.runtime.types.IStruct format)
      Formats all cells in a single column in the active sheet
      Parameters:
      column - The column number (1-based)
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatColumn

      public SpreadsheetFile formatColumn(String sheetName, int column, ortus.boxlang.runtime.types.IStruct format)
      Formats all cells in a single column in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      column - The column number (1-based)
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatColumns

      public SpreadsheetFile formatColumns(String columns, ortus.boxlang.runtime.types.IStruct format)
      Formats multiple columns in the active sheet Column specification format: "1,3,5" or "1-5,7-10" or combinations
      Parameters:
      columns - A string specifying which columns to format
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • formatColumns

      public SpreadsheetFile formatColumns(String sheetName, String columns, ortus.boxlang.runtime.types.IStruct format)
      Formats multiple columns in the specified sheet Column specification format: "1,3,5" or "1-5,7-10" or combinations
      Parameters:
      sheetName - The name of the sheet
      columns - A string specifying which columns to format
      format - A structure containing formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • setRowData

      public SpreadsheetFile setRowData(int row, ortus.boxlang.runtime.types.Array values)
      Sets multiple cell values from a row of data
      Parameters:
      row - The row number (1-based)
      values - Array of values to set starting from column 1
      Returns:
      This SpreadsheetFile instance for method chaining
    • setRowData

      public SpreadsheetFile setRowData(String sheetName, int row, ortus.boxlang.runtime.types.Array values)
      Sets multiple cell values from a row of data in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      row - The row number (1-based)
      values - Array of values to set starting from column 1
      Returns:
      This SpreadsheetFile instance for method chaining
    • getRowData

      public ortus.boxlang.runtime.types.Array getRowData(int row)
      Gets all cell values from a row
      Parameters:
      row - The row number (1-based)
      Returns:
      Array of cell values
    • getRowData

      public ortus.boxlang.runtime.types.Array getRowData(String sheetName, int row)
      Gets all cell values from a row in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      row - The row number (1-based)
      Returns:
      Array of cell values
    • addRow

      public SpreadsheetFile addRow(String values)
      Adds a new row with the specified data at the end of the active sheet
      Parameters:
      values - Comma-separated string of values to add as a new row
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRow

      public SpreadsheetFile addRow(ortus.boxlang.runtime.types.Array values)
      Adds a new row with the specified data at the end of the active sheet
      Parameters:
      values - Array of values to add as a new row
      Returns:
      This SpreadsheetFile instance for method chaining
    • process

      public SpreadsheetFile process(String path, Consumer<ortus.boxlang.runtime.types.Array> rowConsumer)
      Stream rows from a spreadsheet file on disk using true streaming (memory efficient). This uses the excel-streaming-reader library for memory-efficient processing of large files. Rows are provided as a BoxLang Array where each element is the typed value of the cell (String, Double, Boolean, Date, or null).
      Parameters:
      path - Absolute path to the spreadsheet file to process
      rowConsumer - Consumer that receives each row as a BoxLang Array
      Returns:
      This SpreadsheetFile instance for method chaining
    • process

      public SpreadsheetFile process(String path, String sheetName, Consumer<ortus.boxlang.runtime.types.Array> rowConsumer)
      Stream rows from a specific sheet in a spreadsheet file on disk using true streaming. This uses the excel-streaming-reader library for memory-efficient processing of large files.
      Parameters:
      path - Absolute path to the spreadsheet file to process
      sheetName - Name of the sheet to process (null for first sheet)
      rowConsumer - Consumer that receives each row as a BoxLang Array
      Returns:
      This SpreadsheetFile instance for method chaining
    • process

      public SpreadsheetFile process(Consumer<ortus.boxlang.runtime.types.Array> rowConsumer)
      Stream rows from the currently-loaded workbook (this.workbook). If no workbook is loaded, but a path is set, the file will be read and processed using streaming. Throws if neither is available.
      Parameters:
      rowConsumer - Consumer that receives each row as a BoxLang Array
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRow

      public SpreadsheetFile addRow(ortus.boxlang.runtime.types.Array values, int row, int column, boolean insert)
      Adds a new row with the specified data at the specified position in the active sheet
      Parameters:
      values - Array of values to add as a new row
      row - The row number (1-based) to insert the new row at
      column - The starting column number (1-based) for the new row
      insert - Whether to insert the row (shifting existing rows down) or overwrite
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRow

      public SpreadsheetFile addRow(String sheetName, ortus.boxlang.runtime.types.Array values)
      Adds a new row with the specified data at the end of the specified sheet
      Parameters:
      sheetName - The name of the sheet
      values - Array of values to add as a new row
      Returns:
      This SpreadsheetFile instance for method chaining
    • getAllData

      public ortus.boxlang.runtime.types.Array getAllData()
      Gets all data from the active sheet as a 2D array
      Returns:
      Array of arrays representing the sheet data
    • getAllData

      public ortus.boxlang.runtime.types.Array getAllData(String sheetName)
      Gets all data from the specified sheet as a 2D array
      Parameters:
      sheetName - The name of the sheet
      Returns:
      Array of arrays representing the sheet data
    • removeRow

      public void removeRow(int rowIndex)
      Removes a row from the active sheet
      Parameters:
      rowIndex - The row number to remove (1-based)
    • deleteColumn

      public SpreadsheetFile deleteColumn(int column)
      Deletes a column by clearing all cells in that column
      Parameters:
      column - The column number to delete (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • deleteColumn

      public SpreadsheetFile deleteColumn(String sheetName, int column)
      Deletes a column by clearing all cells in that column from the specified sheet
      Parameters:
      sheetName - The name of the sheet
      column - The column number to delete (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • deleteColumns

      public SpreadsheetFile deleteColumns(int startColumn, int endColumn)
      Deletes multiple columns by clearing all cells in those columns
      Parameters:
      startColumn - The starting column number (1-based, inclusive)
      endColumn - The ending column number (1-based, inclusive)
      Returns:
      This SpreadsheetFile instance for method chaining
    • deleteColumns

      public SpreadsheetFile deleteColumns(String sheetName, int startColumn, int endColumn)
      Deletes multiple columns by clearing all cells in those columns from the specified sheet
      Parameters:
      sheetName - The name of the sheet
      startColumn - The starting column number (1-based, inclusive)
      endColumn - The ending column number (1-based, inclusive)
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRows

      public SpreadsheetFile addRows(ortus.boxlang.runtime.types.Array data)
      Sets all data for the active sheet from a 2D array We won't include column names by default, this means, row 1 of data will be skipped
      Parameters:
      data - Array of arrays representing the sheet data
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRows

      public SpreadsheetFile addRows(ortus.boxlang.runtime.types.Array data, String sheetName)
      Sets all data for the active sheet from a 2D array We won't include column names by default, this means, row 1 of data will be skipped
      Parameters:
      data - Array of arrays representing the sheet data
      sheetName - The name of the sheet to set data in, it can be a new or existing sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRows

      public SpreadsheetFile addRows(ortus.boxlang.runtime.types.Array data, String sheetName, boolean includeColumnNames)
      Sets all data for the active sheet from a 2D array We won't include column names by default, this means, row 1 of data will be skipped
      Parameters:
      data - Array of arrays representing the sheet data
      sheetName - The name of the sheet to set data in, it can be a new or existing sheet
      includeColumnNames - Whether the first row of data includes column names, and should be inserted at the top
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRows

      public SpreadsheetFile addRows(ortus.boxlang.runtime.types.Array data, boolean includeColumnNames)
      Sets all data for the active sheet from a 2D array
      Parameters:
      data - Array of arrays representing the sheet data
      includeColumnNames - Whether the first row of data includes column names, and should be inserted at the top
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRows

      public SpreadsheetFile addRows(ortus.boxlang.runtime.types.Array data, int row, int column, boolean insert, boolean includeColumnNames)
      Sets all data for the active sheet from a 2D array starting at specified row and column
      Parameters:
      data - Array of arrays representing the sheet data
      row - The starting row number (1-based)
      column - The starting column number (1-based)
      insert - Whether to insert rows (shifting existing rows down) or overwrite
      includeColumnNames - Whether the first row of data includes column names, and should be inserted at the top
      Returns:
      This SpreadsheetFile instance for method chaining
    • addRows

      public SpreadsheetFile addRows(ortus.boxlang.runtime.types.Array data, int row, int column, boolean insert, boolean includeColumnNames, String sheetName)
      Sets all data for the active sheet from a 2D array starting at specified row and column
      Parameters:
      data - Array of arrays representing the sheet data
      row - The starting row number (1-based)
      column - The starting column number (1-based)
      insert - Whether to insert rows (shifting existing rows down) or overwrite
      includeColumnNames - Whether the first row of data includes column names, and should be inserted at the top
      sheetName - The name of the sheet to set data in, it can be a new or existing sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • getDataAsQuery

      public ortus.boxlang.runtime.types.Array getDataAsQuery()
      Gets data from the active sheet as an array of structs (first row as headers)
      Returns:
      Array of structs where keys are column headers
    • getDataAsQuery

      public ortus.boxlang.runtime.types.Array getDataAsQuery(String sheetName)
      Gets data from the specified sheet as an array of structs (first row as headers)
      Parameters:
      sheetName - The name of the sheet
      Returns:
      Array of structs where keys are column headers
    • toArray

      public ortus.boxlang.runtime.types.Array toArray()
      Converts the active sheet data to an array of structs (first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
      Returns:
      Array of structs where keys are column headers
    • toArray

      public ortus.boxlang.runtime.types.Array toArray(String sheetName)
      Converts the specified sheet data to an array of structs (first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
      Parameters:
      sheetName - The name of the sheet
      Returns:
      Array of structs where keys are column headers
    • toQuery

      public ortus.boxlang.runtime.types.Array toQuery()
      Converts the active sheet data to query format (array of structs with first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
      Returns:
      Array of structs where keys are column headers
    • toQuery

      public ortus.boxlang.runtime.types.Array toQuery(String sheetName)
      Converts the specified sheet data to query format (array of structs with first row as headers) Alias for getDataAsQuery() to match the fluent API pattern
      Parameters:
      sheetName - The name of the sheet
      Returns:
      Array of structs where keys are column headers
    • toJson

      public String toJson()
      Converts the active sheet data to JSON string
      Returns:
      JSON string representation of the sheet data
    • toJson

      public String toJson(boolean pretty)
      Converts the active sheet data to JSON string
      Parameters:
      pretty - Whether to pretty-print the JSON output
      Returns:
      JSON string representation of the sheet data
    • toJson

      public String toJson(String sheetName, boolean pretty)
      Converts the specified sheet data to JSON string
      Parameters:
      sheetName - The name of the sheet
      Returns:
      JSON string representation of the sheet data
    • toMatrix

      public ortus.boxlang.runtime.types.Array toMatrix()
      Converts the active sheet data to a 2D array matrix (including headers) Returns all rows including the header row as arrays
      Returns:
      Array of arrays representing the sheet data as a matrix
    • toMatrix

      public ortus.boxlang.runtime.types.Array toMatrix(String sheetName)
      Converts the specified sheet data to a 2D array matrix (including headers) Returns all rows including the header row as arrays
      Parameters:
      sheetName - The name of the sheet to convert
      Returns:
      Array of arrays representing the sheet data as a matrix
    • toCSV

      public String toCSV()
      Converts the active sheet data to CSV format with default options Default options: comma delimiter, includes headers, CRLF line separator
      Returns:
      CSV string representation of the sheet data
    • toCSV

      public String toCSV(ortus.boxlang.runtime.types.IStruct options)
      Converts the active sheet data to CSV format with custom options
      Parameters:
      options - A struct containing CSV options: - delimiter (String): The delimiter to use between values (default: ",") - includeHeaders (Boolean): Whether to include the header row (default: true) - lineSeparator (String): The line separator to use (default: "\r\n")
      Returns:
      CSV string representation of the sheet data
    • toCSV

      public String toCSV(String sheetName)
      Converts the specified sheet data to CSV format with default options
      Parameters:
      sheetName - The name of the sheet to convert
      Returns:
      CSV string representation of the sheet data
    • toCSV

      public String toCSV(String sheetName, ortus.boxlang.runtime.types.IStruct options)
      Converts the specified sheet data to CSV format with custom options
      Parameters:
      sheetName - The name of the sheet to convert
      options - A struct containing CSV options: - delimiter (String): The delimiter to use between values (default: ",") - includeHeaders (Boolean): Whether to include the header row (default: true) - lineSeparator (String): The line separator to use (default: "\r\n")
      Returns:
      CSV string representation of the sheet data
    • autoSizeColumns

      public SpreadsheetFile autoSizeColumns()
      Auto-sizes all columns in the active sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • autoSizeColumns

      public SpreadsheetFile autoSizeColumns(String sheetName)
      Auto-sizes all columns in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      Returns:
      This SpreadsheetFile instance for method chaining
    • autoSizeColumn

      public SpreadsheetFile autoSizeColumn(int column)
      Auto-sizes a specific column in the active sheet
      Parameters:
      column - The column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • autoSizeColumn

      public SpreadsheetFile autoSizeColumn(String sheetName, int column)
      Auto-sizes a specific column in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      column - The column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getPath

      public String getPath()
      Gets the file path
      Returns:
      The file path
    • getWorkbook

      public org.apache.poi.ss.usermodel.Workbook getWorkbook()
      Gets the underlying Apache POI workbook
      Returns:
      The workbook instance
    • getActiveSheet

      public org.apache.poi.ss.usermodel.Sheet getActiveSheet()
      Gets the active sheet
      Returns:
      The active sheet
    • getSheet

      public org.apache.poi.ss.usermodel.Sheet getSheet(String sheetName)
      Get a sheet by name
      Parameters:
      sheetName - The name of the sheet
      Returns:
      The sheet instance or null if not found
    • getOrCreateSheet

      public org.apache.poi.ss.usermodel.Sheet getOrCreateSheet(String sheetName)
      Get a sheet by name or create it if it doesn't exist
      Parameters:
      sheetName - The name of the sheet
    • getActiveSheetName

      public String getActiveSheetName()
      Gets the name of the active sheet
      Returns:
      The active sheet name
    • getSheetCount

      public int getSheetCount()
      Gets the number of sheets in the workbook
      Returns:
      The number of sheets
    • getSheetNames

      public ortus.boxlang.runtime.types.Array getSheetNames()
      Gets all sheet names
      Returns:
      Array of sheet names
    • getSheetsVisibility

      public ortus.boxlang.runtime.types.IStruct getSheetsVisibility()
      Get all the sheet visibility information as a Struct
      Returns:
      A struct with sheet names as keys and visibility status as values
    • hasSheet

      public boolean hasSheet(String sheetName)
      Checks if a sheet exists
      Parameters:
      sheetName - The name of the sheet
      Returns:
      True if the sheet exists, false otherwise
    • getRowCount

      public int getRowCount()
      Gets the number of rows in the active sheet
      Returns:
      The number of rows
    • getRowCount

      public int getRowCount(String sheetName)
      Gets the number of rows in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      Returns:
      The number of rows
    • getColumnCount

      public int getColumnCount()
      Gets the number of columns in the active sheet
      Returns:
      The number of columns
    • getColumnNames

      public ortus.boxlang.runtime.types.Array getColumnNames()
      Gets the column names for the active sheet. If the first row contains data, it returns those values as column names. If no data is present in the first row, returns Excel-style column identifiers (A, B, C, etc.)
      Returns:
      Array of column names or Excel column identifiers
    • getColumnTypes

      public ortus.boxlang.runtime.types.Array getColumnTypes()
      Gets the column types for the active sheet by analyzing the data in the second row (assuming first row is headers). Returns array of type strings: "string", "numeric", or "date"
      Returns:
      Array of column type strings ("string", "numeric", "date")
    • getColumnCount

      public int getColumnCount(String sheetName)
      Gets the number of columns in the specified sheet
      Parameters:
      sheetName - The name of the sheet
      Returns:
      The number of columns
    • getColumnNames

      public ortus.boxlang.runtime.types.Array getColumnNames(String sheetName)
      Gets the column names for the specified sheet. If the first row contains data, it returns those values as column names. If no data is present in the first row, returns Excel-style column identifiers (A, B, C, etc.)
      Parameters:
      sheetName - The name of the sheet
      Returns:
      Array of column names or Excel column identifiers
    • getColumnTypes

      public ortus.boxlang.runtime.types.Array getColumnTypes(String sheetName)
      Gets the column types for the specified sheet by analyzing the data in the second row (assuming first row is headers). Returns array of type strings: "string", "numeric", or "date"
      Parameters:
      sheetName - The name of the sheet
      Returns:
      Array of column type strings ("string", "numeric", "date")
    • isXmlFormat

      public boolean isXmlFormat()
      Checks if the workbook is in XML format (.xlsx)
      Returns:
      True if XML format, false if binary format
    • isBinaryFormat

      public boolean isBinaryFormat()
      Gets whether the spreadsheet is in binary format (.xls)
      Returns:
      True if format is binary, false if XML
    • isOverwriteEnabled

      public boolean isOverwriteEnabled()
      Gets whether overwrite is enabled
      Returns:
      True if overwrite is enabled, false otherwise
    • addFreezePane

      public SpreadsheetFile addFreezePane(int column, int row)
      Adds a freeze pane to the active sheet
      Parameters:
      column - The column boundary (columns to the left are frozen)
      row - The row boundary (rows above are frozen)
      Returns:
      This SpreadsheetFile instance for method chaining
    • addFreezePane

      public SpreadsheetFile addFreezePane(int column, int row, int endColumn, int endRow)
      Adds a freeze pane to the active sheet with end boundaries
      Parameters:
      column - The column boundary (columns to the left are frozen)
      row - The row boundary (rows above are frozen)
      endColumn - End column boundary (optional)
      endRow - End row boundary (optional)
      Returns:
      This SpreadsheetFile instance for method chaining
    • addSplitPane

      public SpreadsheetFile addSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
      Adds a split pane to the active sheet
      Parameters:
      xSplitPos - The horizontal (x-axis) position of the split in 1/20th of a pixel units
      ySplitPos - The vertical (y-axis) position of the split in 1/20th of a pixel units
      leftmostColumn - The leftmost column visible in the right pane (1-based)
      topRow - The top row visible in the bottom pane (1-based)
      activePane - The active pane (0=lower-left, 1=upper-right, 2=lower-right, 3=upper-left)
      Returns:
      This SpreadsheetFile instance for method chaining
    • addSplitPane

      public SpreadsheetFile addSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow)
      Adds a split pane to the active sheet with default active pane (LOWER_RIGHT)
      Parameters:
      xSplitPos - The horizontal (x-axis) position of the split in 1/20th of a pixel units
      ySplitPos - The vertical (y-axis) position of the split in 1/20th of a pixel units
      leftmostColumn - The leftmost column visible in the right pane (1-based)
      topRow - The top row visible in the bottom pane (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setRowBreak

      public SpreadsheetFile setRowBreak(int row)
      Sets a page (row) break at the specified 1-based row index on the active sheet.
      Parameters:
      row - 1-based row number
      Returns:
      this
    • removeRowBreak

      public SpreadsheetFile removeRowBreak(int row)
      Removes a page (row) break at the specified 1-based row index on the active sheet.
      Parameters:
      row - 1-based row number
      Returns:
      this
    • setColumnBreak

      public SpreadsheetFile setColumnBreak(int column)
      Sets a page (column) break at the specified 1-based column index on the active sheet.
      Parameters:
      column - 1-based column number
      Returns:
      this
    • removeColumnBreak

      public SpreadsheetFile removeColumnBreak(int column)
      Removes a page (column) break at the specified 1-based column index on the active sheet.
      Parameters:
      column - 1-based column number
      Returns:
      this
    • setFitToPage

      public SpreadsheetFile setFitToPage(boolean fitToPage, int pagesWide, int pagesHigh)
      Sets the fit-to-page print option for the active sheet
      Parameters:
      fitToPage - Whether to enable fit-to-page printing
      pagesWide - Number of pages to fit the sheet's columns into (0 = no horizontal constraint)
      pagesHigh - Number of pages to fit the sheet's rows into (0 = no vertical constraint)
      Returns:
      This SpreadsheetFile instance for method chaining
    • addPrintGridlines

      public SpreadsheetFile addPrintGridlines()
      Adds print gridlines to the active sheet (gridlines will print)
      Returns:
      This SpreadsheetFile instance for method chaining
    • removePrintGridlines

      public SpreadsheetFile removePrintGridlines()
      Removes print gridlines from the active sheet (gridlines will not print)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getColumnWidth

      public double getColumnWidth(int column, boolean returnWidthInPixels)
      Gets the width of a column in the active sheet.
      Parameters:
      column - The column number (1-based)
      returnWidthInPixels - If true, returns width in pixels; if false, returns width in points (default: true)
      Returns:
      Column width as a double value
    • getColumnWidth

      public double getColumnWidth(int column)
      Gets the width of a column in the active sheet (defaults to pixels).
      Parameters:
      column - The column number (1-based)
      Returns:
      Column width in pixels
    • getLastRowNumber

      public int getLastRowNumber()
      Gets the last row number with data in the active sheet.
      Returns:
      The last row number (1-based), or 0 if sheet is empty
    • getPrintOrientation

      public String getPrintOrientation()
      Gets the print orientation of the active sheet.
      Returns:
      "portrait" or "landscape"
    • setColumnHidden

      public SpreadsheetFile setColumnHidden(int column, boolean hidden)
      Sets the hidden state of a column on the active sheet
      Parameters:
      column - The column number (1-based)
      hidden - True to hide, false to show
      Returns:
      This SpreadsheetFile instance for method chaining
    • hideColumn

      public SpreadsheetFile hideColumn(int column)
      Hides a column on the active sheet (fluent API)
      Parameters:
      column - The column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • showColumn

      public SpreadsheetFile showColumn(int column)
      Shows a hidden column on the active sheet (fluent API)
      Parameters:
      column - The column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • isColumnHidden

      public boolean isColumnHidden(int column)
      Gets the hidden state of a column on the active sheet
      Parameters:
      column - The column number (1-based)
      Returns:
      true if hidden, false otherwise
    • setRowHidden

      public SpreadsheetFile setRowHidden(int row, boolean hidden)
      Sets the hidden state of a row on the active sheet
      Parameters:
      row - The row number (1-based)
      hidden - True to hide, false to show
      Returns:
      This SpreadsheetFile instance for method chaining
    • hideRow

      public SpreadsheetFile hideRow(int row)
      Hides a row on the active sheet (fluent API)
      Parameters:
      row - The row number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • showRow

      public SpreadsheetFile showRow(int row)
      Shows a hidden row on the active sheet (fluent API)
      Parameters:
      row - The row number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • isRowHidden

      public boolean isRowHidden(int row)
      Gets the hidden state of a row on the active sheet
      Parameters:
      row - The row number (1-based)
      Returns:
      true if hidden, false otherwise
    • addImage

      public SpreadsheetFile addImage(String filepath, int row, int column)
      Adds an image to the active sheet at the specified cell position
      Parameters:
      filepath - The absolute path to the image file (jpg, jpeg, png, or dib)
      row - The starting row (1-based)
      column - The starting column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • addImage

      public SpreadsheetFile addImage(String filepath, int startRow, int startCol, int endRow, int endCol)
      Adds an image to the active sheet with custom anchor dimensions
      Parameters:
      filepath - The absolute path to the image file (jpg, jpeg, png, or dib)
      startRow - The starting row (1-based)
      startCol - The starting column (1-based)
      endRow - The ending row (1-based)
      endCol - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setHeader

      public SpreadsheetFile setHeader(ortus.boxlang.runtime.types.IStruct header)
      Sets the header for the active sheet using a struct with optional keys: left, center, right
      Parameters:
      header - The header struct
      Returns:
      This SpreadsheetFile instance for chaining
    • setFooter

      public SpreadsheetFile setFooter(ortus.boxlang.runtime.types.IStruct footer)
      Sets the footer for the active sheet using a struct with optional keys: left, center, right
      Parameters:
      footer - The footer struct
      Returns:
      This SpreadsheetFile instance for chaining
    • setHeaderImage

      public SpreadsheetFile setHeaderImage(String alignment, String imagePath)
      Sets an image in the header of the active sheet
      Parameters:
      alignment - The alignment: "left", "center", or "right"
      imagePath - The absolute path to the image file
      Returns:
      This SpreadsheetFile instance for chaining
    • setFooterImage

      public SpreadsheetFile setFooterImage(String alignment, String imagePath)
      Sets an image in the footer of the active sheet
      Parameters:
      alignment - The alignment: "left", "center", or "right"
      imagePath - The absolute path to the image file
      Returns:
      This SpreadsheetFile instance for chaining
    • addAutofilter

      public SpreadsheetFile addAutofilter(int startRow, int startColumn, int endRow, int endColumn)
      Adds autofilter to a range in the active sheet
      Parameters:
      startRow - The starting row (1-based)
      startColumn - The starting column (1-based)
      endRow - The ending row (1-based)
      endColumn - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • mergeCells

      public SpreadsheetFile mergeCells(int startRow, int startColumn, int endRow, int endColumn)
      Merges cells in the active sheet
      Parameters:
      startRow - The starting row (1-based)
      startColumn - The starting column (1-based)
      endRow - The ending row (1-based)
      endColumn - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellFormula

      public SpreadsheetFile setCellFormula(int row, int col, String formula)
      Sets cell formula in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      formula - The formula to set (without leading =)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getCellFormula

      public String getCellFormula(int row, int col)
      Gets cell formula from the active sheet and a specified cell
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      The formula as a string, or null if no formula
    • getAllFormulas

      public ortus.boxlang.runtime.types.Array getAllFormulas()
      Gets all cell formulas from the active sheet as a 2D array with each value being a struct with the following keys: - formula : The cell formula as a string - row : The row number (1-based) - column : The column number (1-based)
      Returns:
      2D Array of cell formulas (null for cells without formulas)
    • setColumnWidth

      public SpreadsheetFile setColumnWidth(int column, double width)
      Sets the width of a column in the active sheet
      Parameters:
      column - The column number (1-based)
      width - The width in Excel units
      Returns:
      This SpreadsheetFile instance for method chaining
    • setRowHeight

      public SpreadsheetFile setRowHeight(int row, double height)
      Sets the height of a row in the active sheet
      Parameters:
      row - The row number (1-based)
      height - The height in points
      Returns:
      This SpreadsheetFile instance for method chaining
    • shiftRows

      public SpreadsheetFile shiftRows(int start, int end, int n)
      Shifts rows up or down in the active sheet
      Parameters:
      start - The starting row number (1-based)
      end - The ending row number (1-based)
      n - The number of rows to shift (positive for down, negative for up)
      Returns:
      This SpreadsheetFile instance for method chaining
    • shiftRows

      public SpreadsheetFile shiftRows(int start)
      Shifts rows up or down in the active sheet (single row, default shift down by 1)
      Parameters:
      start - The starting row number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • shiftRows

      public SpreadsheetFile shiftRows(int start, int n)
      Shifts rows up or down in the active sheet (single row with shift amount)
      Parameters:
      start - The starting row number (1-based)
      n - The number of rows to shift (positive for down, negative for up)
      Returns:
      This SpreadsheetFile instance for method chaining
    • shiftColumns

      public SpreadsheetFile shiftColumns(int start, int end, int n)
      Shifts columns left or right in the active sheet
      Parameters:
      start - The starting column number (1-based)
      end - The ending column number (1-based)
      n - The number of columns to shift (positive for right, negative for left)
      Returns:
      This SpreadsheetFile instance for method chaining
    • shiftColumns

      public SpreadsheetFile shiftColumns(int start)
      Shifts columns left or right in the active sheet (single column, default shift right by 1)
      Parameters:
      start - The starting column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • shiftColumns

      public SpreadsheetFile shiftColumns(int start, int n)
      Shifts columns left or right in the active sheet (single column with shift amount)
      Parameters:
      start - The starting column number (1-based)
      n - The number of columns to shift (positive for right, negative for left)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellComment

      public SpreadsheetFile setCellComment(int row, int col, String comment)
      Sets a comment on a cell in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      comment - The comment text
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellComment

      public SpreadsheetFile setCellComment(int row, int col, String comment, String author)
      Sets a comment on a cell in the active sheet with an author
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      comment - The comment text
      author - The comment author
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellComment

      public SpreadsheetFile setCellComment(int row, int col, ortus.boxlang.runtime.types.IStruct commentStruct)
      Sets a comment on a cell in the active sheet from a struct with formatting options
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      commentStruct - A struct with comment details and formatting options
      Returns:
      This SpreadsheetFile instance for method chaining
    • getCellComment

      public ortus.boxlang.runtime.types.IStruct getCellComment(int row, int col)
      Gets a comment from a cell in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      The comment as a struct with {Author, Column, Comment, Row}, or null if no comment exists
    • getAllCellComments

      public ortus.boxlang.runtime.types.Array getAllCellComments()
      Gets all comments from the active sheet
      Returns:
      An array of structs with {Author, Column, Comment, Row} for each comment in the sheet
    • setInfo

      public SpreadsheetFile setInfo(ortus.boxlang.runtime.types.IStruct properties)
      Sets document properties/metadata for the workbook (alias for addInfo)
      Parameters:
      properties - A struct containing metadata properties (AUTHOR, TITLE, SUBJECT, COMMENTS, KEYWORDS, CATEGORY, LASTAUTHOR)
      Returns:
      this - for method chaining
    • clearCell

      public SpreadsheetFile clearCell(int row, int col)
      Clears the specified cell of all styles and values in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • clearSheet

      public SpreadsheetFile clearSheet(String sheetName)
      Clears all data from the specified sheet
      Parameters:
      sheetName - The name of the sheet to clear
      Returns:
      This SpreadsheetFile instance for method chaining
    • clearCellRange

      public SpreadsheetFile clearCellRange(int startRow, int startCol, int endRow, int endCol)
      Clears a range of cells of all styles and values in the active sheet
      Parameters:
      startRow - The starting row (1-based, inclusive)
      startCol - The starting column (1-based, inclusive)
      endRow - The ending row (1-based, inclusive)
      endCol - The ending column (1-based, inclusive)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getCellType

      public String getCellType(int row, int col)
      Gets the Excel cell type of the specified cell in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      Cell type as a string: "BLANK", "BOOLEAN", "ERROR", "FORMULA", "NUMERIC", or "STRING"
    • getCellFormat

      public ortus.boxlang.runtime.types.IStruct getCellFormat(int row, int col)
      Gets the formatting information of the specified cell in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      A struct containing all formatting attributes of the cell
    • setCellRangeValue

      public SpreadsheetFile setCellRangeValue(Object value, int startRow, int startCol, int endRow, int endCol)
      Sets the same value to a range of cells in the active sheet
      Parameters:
      value - The value to set for all cells in the range
      startRow - The starting row (1-based)
      startCol - The starting column (1-based)
      endRow - The ending row (1-based)
      endCol - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getActiveCell

      public ortus.boxlang.runtime.types.IStruct getActiveCell()
      Gets the currently active/selected cell in the active sheet
      Returns:
      A struct with keys "row" and "column" (both 1-based)
    • setActiveCell

      public SpreadsheetFile setActiveCell(int row, int col)
      Sets the active/selected cell in the active sheet
      Parameters:
      row - The row number (1-based)
      col - The column number (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellHyperlink

      public SpreadsheetFile setCellHyperlink(int row, int column, String hyperlink, String label)
      Sets a hyperlink on a cell in the active sheet
      Parameters:
      row - The row number (1-based)
      column - The column number (1-based)
      hyperlink - The hyperlink URL
      label - The optional display label for the hyperlink
      Returns:
      This SpreadsheetFile instance for method chaining
    • setCellHyperlink

      public SpreadsheetFile setCellHyperlink(int row, int column, String hyperlink)
      Sets a hyperlink on a cell in the active sheet (without a custom label)
      Parameters:
      row - The row number (1-based)
      column - The column number (1-based)
      hyperlink - The hyperlink URL
      Returns:
      This SpreadsheetFile instance for method chaining
    • getCellHyperlink

      public ortus.boxlang.runtime.types.IStruct getCellHyperlink(int row, int column)
      Gets the hyperlink from a cell in the active sheet
      Parameters:
      row - The row number (1-based)
      column - The column number (1-based)
      Returns:
      A struct containing hyperlink information (url, label, type), or null if no hyperlink exists
    • formatCellRange

      public SpreadsheetFile formatCellRange(ortus.boxlang.runtime.types.IStruct format, int startRow, int startCol, int endRow, int endCol)
      Formats a range of cells in the active sheet with a single format struct
      Parameters:
      format - The format struct containing style properties
      startRow - The starting row (1-based)
      startCol - The starting column (1-based)
      endRow - The ending row (1-based)
      endCol - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setSheetPrintOrientation

      public SpreadsheetFile setSheetPrintOrientation(String orientation)
      Sets the print orientation for the active sheet
      Parameters:
      orientation - The orientation ("portrait" or "landscape")
      Returns:
      This SpreadsheetFile instance for method chaining
    • setRepeatingColumns

      public SpreadsheetFile setRepeatingColumns(int startCol, int endCol)
      Sets columns to repeat on every printed page for the active sheet
      Parameters:
      startCol - The starting column (1-based)
      endCol - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • setRepeatingRows

      public SpreadsheetFile setRepeatingRows(int startRow, int endRow)
      Sets rows to repeat on every printed page for the active sheet
      Parameters:
      startRow - The starting row (1-based)
      endRow - The ending row (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • groupRows

      public SpreadsheetFile groupRows(int startRow, int endRow, Boolean isCollapsed)
      Groups rows together in the active sheet for outline/collapse functionality
      Parameters:
      startRow - The starting row (1-based)
      endRow - The ending row (1-based)
      isCollapsed - Whether the group should be initially collapsed (default: false)
      Returns:
      This SpreadsheetFile instance for method chaining
    • groupRows

      public SpreadsheetFile groupRows(int startRow, int endRow)
      Groups rows together in the active sheet (expanded by default)
      Parameters:
      startRow - The starting row (1-based)
      endRow - The ending row (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • ungroupRows

      public SpreadsheetFile ungroupRows(int startRow, int endRow)
      Ungroups rows in the active sheet
      Parameters:
      startRow - The starting row (1-based)
      endRow - The ending row (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • groupColumns

      public SpreadsheetFile groupColumns(int startColumn, int endColumn, Boolean isCollapsed)
      Groups columns together in the active sheet for outline/collapse functionality
      Parameters:
      startColumn - The starting column (1-based)
      endColumn - The ending column (1-based)
      isCollapsed - Whether the group should be initially collapsed (default: false)
      Returns:
      This SpreadsheetFile instance for method chaining
    • groupColumns

      public SpreadsheetFile groupColumns(int startColumn, int endColumn)
      Groups columns together in the active sheet (expanded by default)
      Parameters:
      startColumn - The starting column (1-based)
      endColumn - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • ungroupColumns

      public SpreadsheetFile ungroupColumns(int startColumn, int endColumn)
      Ungroups columns in the active sheet
      Parameters:
      startColumn - The starting column (1-based)
      endColumn - The ending column (1-based)
      Returns:
      This SpreadsheetFile instance for method chaining
    • getAutoCalculate

      public boolean getAutoCalculate()
      Gets whether formulas automatically calculate
      Returns:
      True if auto-calculation is enabled, false otherwise
    • setAutoCalculate

      public SpreadsheetFile setAutoCalculate(boolean autoCalculate)
      Sets whether formulas automatically calculate
      Parameters:
      autoCalculate - Whether to enable auto-calculation
      Returns:
      This SpreadsheetFile instance for method chaining
    • getRecalculateFormulasOnNextOpen

      public boolean getRecalculateFormulasOnNextOpen()
      Gets whether formulas will be recalculated when the file is opened
      Returns:
      True if force recalculation is enabled, false otherwise
    • setRecalculateFormulasOnNextOpen

      public SpreadsheetFile setRecalculateFormulasOnNextOpen(boolean recalculate)
      Sets whether formulas should be recalculated when the file is opened
      Parameters:
      recalculate - Whether to force recalculation on next open
      Returns:
      This SpreadsheetFile instance for method chaining
    • close

      public void close()
      Closes the workbook and releases resources
    • isClosed

      public boolean isClosed()
      Checks if the workbook has been closed
      Returns:
      true if closed, false otherwise
    • toString

      public String toString()
      String representation of the spreadsheet file
      Overrides:
      toString in class Object