Package ortus.boxlang.spreadsheet
Class SpreadsheetFile
java.lang.Object
ortus.boxlang.spreadsheet.SpreadsheetFile
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
FieldsModifier and TypeFieldDescriptionstatic final String------------------------------------------------------------------------ Constants ------------------------------------------------------------------------ -
Constructor Summary
ConstructorsConstructorDescriptionConstructor - initializes a new SpreadsheetFile instance Creates a new workbook with a default sheet named "Sheet1" and using the xlsx formatSpreadsheetFile(boolean xmlFormat) Constructor with format specificationSpreadsheetFile(boolean xmlFormat, String sheetName) Constructor with format specification and sheet name -
Method Summary
Modifier and TypeMethodDescriptionaddAutofilter(int startRow, int startColumn, int endRow, int endColumn) Adds autofilter to a range in the active sheetaddFreezePane(int column, int row) Adds a freeze pane to the active sheetaddFreezePane(int column, int row, int endColumn, int endRow) Adds a freeze pane to the active sheet with end boundariesAdds an image to the active sheet at the specified cell positionAdds an image to the active sheet with custom anchor dimensionsAdds print gridlines to the active sheet (gridlines will print)Adds a new row with the specified data at the end of the active sheetAdds a new row with the specified data at the end of the specified sheetaddRow(ortus.boxlang.runtime.types.Array values) Adds a new row with the specified data at the end of the active sheetaddRow(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 sheetaddRows(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 skippedaddRows(ortus.boxlang.runtime.types.Array data, boolean includeColumnNames) Sets all data for the active sheet from a 2D arrayaddRows(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 columnaddRows(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 columnSets 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 skippedSets 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 skippedaddSplitPane(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 sheetautoCloseOnSave(boolean autoClose) Sets whether to auto close the workbook when savingautoSizeColumn(int column) Auto-sizes a specific column in the active sheetautoSizeColumn(String sheetName, int column) Auto-sizes a specific column in the specified sheetAuto-sizes all columns in the active sheetautoSizeColumns(String sheetName) Auto-sizes all columns in the specified sheetclearCell(int row, int col) Clears the specified cell of all styles and values in the active sheetclearCellRange(int startRow, int startCol, int endRow, int endCol) Clears a range of cells of all styles and values in the active sheetclearSheet(String sheetName) Clears all data from the specified sheetvoidclose()Closes the workbook and releases resourcesCopies a sheet with a new name Creates a complete copy of the source sheet including all data, formatting, and structurecreateAndSelectSheet(String sheetName) Creates a new sheet and makes it the active sheetcreateAndSelectSheet(String sheetName, boolean overwrite) Creates a new sheet and makes it the active sheetcreateSheet(String sheetName) Creates a new sheet with the specified namecreateSheet(String sheetName, boolean overwrite) Creates a new sheet with the specified namedeleteColumn(int column) Deletes a column by clearing all cells in that columndeleteColumn(String sheetName, int column) Deletes a column by clearing all cells in that column from the specified sheetdeleteColumns(int startColumn, int endColumn) Deletes multiple columns by clearing all cells in those columnsdeleteColumns(String sheetName, int startColumn, int endColumn) Deletes multiple columns by clearing all cells in those columns from the specified sheetformatCell(int row, int col, ortus.boxlang.runtime.types.IStruct format) Formats a cell in the active sheetformatCell(String sheetName, int row, int col, ortus.boxlang.runtime.types.IStruct format) Formats a cell in the specified sheetformatCellRange(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 structformatColumn(int column, ortus.boxlang.runtime.types.IStruct format) Formats all cells in a single column in the active sheetformatColumn(String sheetName, int column, ortus.boxlang.runtime.types.IStruct format) Formats all cells in a single column in the specified sheetformatColumns(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 combinationsformatColumns(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 combinationsformatRow(int row, ortus.boxlang.runtime.types.IStruct format) Formats all cells in a single row in the active sheetFormats all cells in a single row in the specified sheetformatRows(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 combinationsformatRows(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 combinationsstatic SpreadsheetFilefromArray(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 rowstatic SpreadsheetFileCreates 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 headersstatic SpreadsheetFilefromQuery(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 patternstatic SpreadsheetFilefromWorkbook(org.apache.poi.ss.usermodel.Workbook workbook) Creates a new SpreadsheetFile from an existing workbookortus.boxlang.runtime.types.IStructGets the currently active/selected cell in the active sheetorg.apache.poi.ss.usermodel.SheetGets the active sheetGets the name of the active sheetortus.boxlang.runtime.types.ArrayGets all comments from the active sheetortus.boxlang.runtime.types.ArrayGets all data from the active sheet as a 2D arrayortus.boxlang.runtime.types.ArraygetAllData(String sheetName) Gets all data from the specified sheet as a 2D arrayortus.boxlang.runtime.types.ArrayGets 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)booleanGets whether formulas automatically calculategetCellAddress(int row, int column) Gets the cell address string for a given row and column (e.g., "A1", "B5")ortus.boxlang.runtime.types.IStructgetCellComment(int row, int col) Gets a comment from a cell in the active sheetortus.boxlang.runtime.types.IStructgetCellFormat(int row, int col) Gets the formatting information of the specified cell in the active sheetgetCellFormula(int row, int col) Gets cell formula from the active sheet and a specified cellortus.boxlang.runtime.types.IStructgetCellHyperlink(int row, int column) Gets the hyperlink from a cell in the active sheetgetCellType(int row, int col) Gets the Excel cell type of the specified cell in the active sheetgetCellValue(int row, int col) Gets a cell value at the specified row and column in the active sheetgetCellValue(String sheetName, int row, int col) Gets a cell value at the specified row and column in the specified sheetintGets the number of columns in the active sheetintgetColumnCount(String sheetName) Gets the number of columns in the specified sheetortus.boxlang.runtime.types.ArrayGets the column names for the active sheet.ortus.boxlang.runtime.types.ArraygetColumnNames(String sheetName) Gets the column names for the specified sheet.ortus.boxlang.runtime.types.ArrayGets the column types for the active sheet by analyzing the data in the second row (assuming first row is headers).ortus.boxlang.runtime.types.ArraygetColumnTypes(String sheetName) Gets the column types for the specified sheet by analyzing the data in the second row (assuming first row is headers).doublegetColumnWidth(int column) Gets the width of a column in the active sheet (defaults to pixels).doublegetColumnWidth(int column, boolean returnWidthInPixels) Gets the width of a column in the active sheet.ortus.boxlang.runtime.types.ArrayGets data from the active sheet as an array of structs (first row as headers)ortus.boxlang.runtime.types.ArraygetDataAsQuery(String sheetName) Gets data from the specified sheet as an array of structs (first row as headers)intGets the last row number with data in the active sheet.org.apache.poi.ss.usermodel.SheetgetOrCreateSheet(String sheetName) Get a sheet by name or create it if it doesn't existgetPath()Gets the file pathGets the print orientation of the active sheet.booleanGets whether formulas will be recalculated when the file is openedintGets the number of rows in the active sheetintgetRowCount(String sheetName) Gets the number of rows in the specified sheetortus.boxlang.runtime.types.ArraygetRowData(int row) Gets all cell values from a rowortus.boxlang.runtime.types.ArraygetRowData(String sheetName, int row) Gets all cell values from a row in the specified sheetorg.apache.poi.ss.usermodel.SheetGet a sheet by nameintGets the number of sheets in the workbookortus.boxlang.runtime.types.ArrayGets all sheet namesortus.boxlang.runtime.types.IStructGet all the sheet visibility information as a Structorg.apache.poi.ss.usermodel.WorkbookGets the underlying Apache POI workbookgroupColumns(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 functionalitygroupRows(int startRow, int endRow) Groups rows together in the active sheet (expanded by default)Groups rows together in the active sheet for outline/collapse functionalitybooleanChecks if a sheet existshideColumn(int column) Hides a column on the active sheet (fluent API)hideRow(int row) Hides a row on the active sheet (fluent API)Hides a sheet from viewortus.boxlang.runtime.types.IStructinfo()Returns properties of a spreadsheet as a struct.booleanIs auto close on save enabledbooleanGets whether the spreadsheet is in binary format (.xls)booleanisClosed()Checks if the workbook has been closedbooleanisColumnHidden(int column) Gets the hidden state of a column on the active sheetbooleanGets whether overwrite is enabledbooleanisRowHidden(int row) Gets the hidden state of a row on the active sheetbooleanChecks if the workbook is in XML format (.xlsx)Loads a spreadsheet file from the specified pathLoads a spreadsheet file from the specified path with optional passwordmergeCells(int startRow, int startColumn, int endRow, int endColumn) Merges cells in the active sheetmoveSheet(int fromIndex, int toIndex) Moves a sheet to a new position by indexMoves a sheet to a new position by nameoverwrite(boolean overwrite) Sets whether to overwrite existing files when savingStream rows from a specific sheet in a spreadsheet file on disk using true streaming.Stream rows from a spreadsheet file on disk using true streaming (memory efficient).Stream rows from the currently-loaded workbook (this.workbook).Recalculates all formulas in the workbookremoveColumnBreak(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)voidremoveRow(int rowIndex) Removes a row from the active sheetremoveRowBreak(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 namerenameSheet(String oldName, String newName) Renames an existing sheetsave()Saves the spreadsheet to the currently loaded pathSaves the spreadsheet to the specified pathSaves the spreadsheet to the specified path with password protectionSaves the spreadsheet to the currently loaded path and closes the workbooksaveAndClose(String path) Saves the spreadsheet to the currently loaded path and closes the workbooksaveAndClose(String path, String password) Saves the spreadsheet to the specified path with password protection and closes the workbookselectSheet(int sheetIndex) Selects (activates) a sheet by index (1-based)selectSheet(String sheetName) Selects (activates) a sheet by namesetActiveCell(int row, int col) Sets the active/selected cell in the active sheetsetAutoCalculate(boolean autoCalculate) Sets whether formulas automatically calculatesetCellComment(int row, int col, String comment) Sets a comment on a cell in the active sheetsetCellComment(int row, int col, String comment, String author) Sets a comment on a cell in the active sheet with an authorsetCellComment(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 optionssetCellFormula(int row, int col, String formula) Sets cell formula in the active sheetsetCellHyperlink(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 sheetsetCellRangeValue(Object value, int startRow, int startCol, int endRow, int endCol) Sets the same value to a range of cells in the active sheetsetCellValue(int row, int col, Object value) Sets a cell value at the specified row and column in the active sheetsetCellValue(String sheetName, int row, int col, Object value) Sets a cell value at the specified row and column in the specified sheetsetColumnBreak(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 sheetsetColumnWidth(int column, double width) Sets the width of a column in the active sheetsetFitToPage(boolean fitToPage, int pagesWide, int pagesHigh) Sets the fit-to-page print option for the active sheetsetFooter(ortus.boxlang.runtime.types.IStruct footer) Sets the footer for the active sheet using a struct with optional keys: left, center, rightsetFooterImage(String alignment, String imagePath) Sets an image in the footer of the active sheetsetHeader(ortus.boxlang.runtime.types.IStruct header) Sets the header for the active sheet using a struct with optional keys: left, center, rightsetHeaderImage(String alignment, String imagePath) Sets an image in the header of the active sheetsetInfo(ortus.boxlang.runtime.types.IStruct properties) Sets document properties/metadata for the workbook (alias for addInfo)Sets the file path for this spreadsheetsetRecalculateFormulasOnNextOpen(boolean recalculate) Sets whether formulas should be recalculated when the file is openedsetRepeatingColumns(int startCol, int endCol) Sets columns to repeat on every printed page for the active sheetsetRepeatingRows(int startRow, int endRow) Sets rows to repeat on every printed page for the active sheetsetRowBreak(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 datasetRowData(String sheetName, int row, ortus.boxlang.runtime.types.Array values) Sets multiple cell values from a row of data in the specified sheetsetRowHeight(int row, double height) Sets the height of a row in the active sheetsetRowHidden(int row, boolean hidden) Sets the hidden state of a row on the active sheetsetSheetPrintOrientation(String orientation) Sets the print orientation for the active sheetshiftColumns(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 sheetshiftRows(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 sheetshowColumn(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.ArraytoArray()Converts the active sheet data to an array of structs (first row as headers) Alias for getDataAsQuery() to match the fluent API patternortus.boxlang.runtime.types.ArrayConverts the specified sheet data to an array of structs (first row as headers) Alias for getDataAsQuery() to match the fluent API patterntoCSV()Converts the active sheet data to CSV format with default options Default options: comma delimiter, includes headers, CRLF line separatorConverts the specified sheet data to CSV format with default optionsConverts the specified sheet data to CSV format with custom optionstoCSV(ortus.boxlang.runtime.types.IStruct options) Converts the active sheet data to CSV format with custom optionstoJson()Converts the active sheet data to JSON stringtoJson(boolean pretty) Converts the active sheet data to JSON stringConverts the specified sheet data to JSON stringortus.boxlang.runtime.types.ArraytoMatrix()Converts the active sheet data to a 2D array matrix (including headers) Returns all rows including the header row as arraysortus.boxlang.runtime.types.ArrayConverts the specified sheet data to a 2D array matrix (including headers) Returns all rows including the header row as arraysortus.boxlang.runtime.types.ArraytoQuery()Converts the active sheet data to query format (array of structs with first row as headers) Alias for getDataAsQuery() to match the fluent API patternortus.boxlang.runtime.types.ArrayConverts the specified sheet data to query format (array of structs with first row as headers) Alias for getDataAsQuery() to match the fluent API patterntoString()String representation of the spreadsheet fileungroupColumns(int startColumn, int endColumn) Ungroups columns in the active sheetungroupRows(int startRow, int endRow) Ungroups rows in the active sheetunhideSheet(String sheetName) Unhides a sheet to make it visiblestatic SpreadsheetFilexls()Creates a new SpreadsheetFile with .xls formatstatic SpreadsheetFilexlsx()Creates a new SpreadsheetFile with .xlsx format
-
Field Details
-
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
Constructor with format specification and sheet name- Parameters:
xmlFormat- True for .xlsx format, false for .xls formatsheetName- The name of the initial sheet
-
-
Method Details
-
fromWorkbook
Creates a new SpreadsheetFile from an existing workbook- Parameters:
workbook- The Apache POI workbook- Returns:
- A new SpreadsheetFile instance
-
xlsx
Creates a new SpreadsheetFile with .xlsx format- Returns:
- A new SpreadsheetFile instance in XML format
-
xls
Creates a new SpreadsheetFile with .xls format- Returns:
- A new SpreadsheetFile instance in binary format
-
fromJson
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
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
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
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
Loads a spreadsheet file from the specified path with optional password- Parameters:
path- A fully qualified path to a spreadsheet filepassword- Optional password for encrypted files- Returns:
- This SpreadsheetFile instance for method chaining
-
save
Saves the spreadsheet to the currently loaded path- Returns:
- This SpreadsheetFile instance for method chaining
-
saveAndClose
Saves the spreadsheet to the currently loaded path and closes the workbook- Returns:
- This SpreadsheetFile instance for method chaining
-
save
Saves the spreadsheet to the specified path- Parameters:
path- The path to save the file- Returns:
- This SpreadsheetFile instance for method chaining
-
saveAndClose
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
Saves the spreadsheet to the specified path with password protection- Parameters:
path- The path to save the filepassword- The password to protect the file with- Returns:
- This SpreadsheetFile instance for method chaining
-
saveAndClose
Saves the spreadsheet to the specified path with password protection and closes the workbook- Parameters:
path- The path to save the filepassword- The password to protect the file with- Returns:
- This SpreadsheetFile instance for method chaining
-
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
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
Sets the file path for this spreadsheet- Parameters:
path- The file path- Returns:
- This SpreadsheetFile instance for method chaining
-
createSheet
Creates a new sheet with the specified name- Parameters:
sheetName- The name of the new sheetoverwrite- Whether to overwrite an existing sheet with the same name- Returns:
- This SpreadsheetFile instance for method chaining
-
createSheet
Creates a new sheet with the specified name- Parameters:
sheetName- The name of the new sheet- Returns:
- This SpreadsheetFile instance for method chaining
-
createAndSelectSheet
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
Creates a new sheet and makes it the active sheet- Parameters:
sheetName- The name of the new sheetoverwrite- Whether to overwrite an existing sheet with the same name- Returns:
- This SpreadsheetFile instance for method chaining
-
selectSheet
Selects (activates) a sheet by name- Parameters:
sheetName- The name of the sheet to activate- Returns:
- This SpreadsheetFile instance for method chaining
-
selectSheet
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
Removes a sheet by name- Parameters:
sheetName- The name of the sheet to remove- Returns:
- This SpreadsheetFile instance for method chaining
-
removeSheet
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
Renames an existing sheet- Parameters:
oldName- The current name of the sheetnewName- The new name for the sheet- Returns:
- This SpreadsheetFile instance for method chaining
-
copySheet
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 fromtoName- 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
Hides a sheet from view- Parameters:
sheetName- The name of the sheet to hide- Returns:
- This SpreadsheetFile instance for method chaining
-
unhideSheet
Unhides a sheet to make it visible- Parameters:
sheetName- The name of the sheet to unhide- Returns:
- This SpreadsheetFile instance for method chaining
-
moveSheet
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
Moves a sheet to a new position by name- Parameters:
sheetName- The name of the sheet to movetoIndex- The target sheet index (0-based)- Returns:
- This SpreadsheetFile instance for method chaining
-
getCellAddress
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
Recalculates all formulas in the workbook- Returns:
- This SpreadsheetFile instance for method chaining
-
setCellValue
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
Sets a cell value at the specified row and column in the specified sheet- Parameters:
sheetName- The name of the sheetrow- The row number (1-based)col- The column number (1-based)value- The value to set- Returns:
- This SpreadsheetFile instance for method chaining
-
getCellValue
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
Gets a cell value at the specified row and column in the specified sheet- Parameters:
sheetName- The name of the sheetrow- The row number (1-based)col- The column number (1-based)- Returns:
- The cell value
-
formatCell
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 sheetrow- 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
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 sheetrow- The row number (1-based)format- A structure containing formatting options- Returns:
- This SpreadsheetFile instance for method chaining
-
formatRows
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 formatformat- 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 sheetrows- A string specifying which rows to formatformat- A structure containing formatting options- Returns:
- This SpreadsheetFile instance for method chaining
-
formatColumn
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 sheetcolumn- The column number (1-based)format- A structure containing formatting options- Returns:
- This SpreadsheetFile instance for method chaining
-
formatColumns
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 formatformat- 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 sheetcolumns- A string specifying which columns to formatformat- A structure containing formatting options- Returns:
- This SpreadsheetFile instance for method chaining
-
setRowData
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 sheetrow- 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
Gets all cell values from a row in the specified sheet- Parameters:
sheetName- The name of the sheetrow- The row number (1-based)- Returns:
- Array of cell values
-
addRow
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
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 processrowConsumer- 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 processsheetName- 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
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 rowrow- The row number (1-based) to insert the new row atcolumn- The starting column number (1-based) for the new rowinsert- Whether to insert the row (shifting existing rows down) or overwrite- Returns:
- This SpreadsheetFile instance for method chaining
-
addRow
Adds a new row with the specified data at the end of the specified sheet- Parameters:
sheetName- The name of the sheetvalues- 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
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
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
Deletes a column by clearing all cells in that column from the specified sheet- Parameters:
sheetName- The name of the sheetcolumn- The column number to delete (1-based)- Returns:
- This SpreadsheetFile instance for method chaining
-
deleteColumns
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
Deletes multiple columns by clearing all cells in those columns from the specified sheet- Parameters:
sheetName- The name of the sheetstartColumn- The starting column number (1-based, inclusive)endColumn- The ending column number (1-based, inclusive)- Returns:
- This SpreadsheetFile instance for method chaining
-
addRows
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
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 datasheetName- 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 datasheetName- The name of the sheet to set data in, it can be a new or existing sheetincludeColumnNames- Whether the first row of data includes column names, and should be inserted at the top- Returns:
- This SpreadsheetFile instance for method chaining
-
addRows
Sets all data for the active sheet from a 2D array- Parameters:
data- Array of arrays representing the sheet dataincludeColumnNames- 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 datarow- The starting row number (1-based)column- The starting column number (1-based)insert- Whether to insert rows (shifting existing rows down) or overwriteincludeColumnNames- 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 datarow- The starting row number (1-based)column- The starting column number (1-based)insert- Whether to insert rows (shifting existing rows down) or overwriteincludeColumnNames- Whether the first row of data includes column names, and should be inserted at the topsheetName- 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
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
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
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
Converts the active sheet data to JSON string- Returns:
- JSON string representation of the sheet data
-
toJson
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
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
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
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
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
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
Converts the specified sheet data to CSV format with custom options- Parameters:
sheetName- The name of the sheet to convertoptions- 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
Auto-sizes all columns in the active sheet- Returns:
- This SpreadsheetFile instance for method chaining
-
autoSizeColumns
Auto-sizes all columns in the specified sheet- Parameters:
sheetName- The name of the sheet- Returns:
- This SpreadsheetFile instance for method chaining
-
autoSizeColumn
Auto-sizes a specific column in the active sheet- Parameters:
column- The column number (1-based)- Returns:
- This SpreadsheetFile instance for method chaining
-
autoSizeColumn
Auto-sizes a specific column in the specified sheet- Parameters:
sheetName- The name of the sheetcolumn- The column number (1-based)- Returns:
- This SpreadsheetFile instance for method chaining
-
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
Get a sheet by name- Parameters:
sheetName- The name of the sheet- Returns:
- The sheet instance or null if not found
-
getOrCreateSheet
Get a sheet by name or create it if it doesn't exist- Parameters:
sheetName- The name of the sheet
-
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
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
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
Gets the number of columns in the specified sheet- Parameters:
sheetName- The name of the sheet- Returns:
- The number of columns
-
getColumnNames
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
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
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
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 unitsySplitPos- The vertical (y-axis) position of the split in 1/20th of a pixel unitsleftmostColumn- 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
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 unitsySplitPos- The vertical (y-axis) position of the split in 1/20th of a pixel unitsleftmostColumn- 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
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
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
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
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
Sets the fit-to-page print option for the active sheet- Parameters:
fitToPage- Whether to enable fit-to-page printingpagesWide- 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
Adds print gridlines to the active sheet (gridlines will print)- Returns:
- This SpreadsheetFile instance for method chaining
-
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
Gets the print orientation of the active sheet.- Returns:
- "portrait" or "landscape"
-
setColumnHidden
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
Hides a column on the active sheet (fluent API)- Parameters:
column- The column number (1-based)- Returns:
- This SpreadsheetFile instance for method chaining
-
showColumn
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
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
Hides a row on the active sheet (fluent API)- Parameters:
row- The row number (1-based)- Returns:
- This SpreadsheetFile instance for method chaining
-
showRow
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
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
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
-
setHeaderImage
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
-
addAutofilter
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
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
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
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
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
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
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
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
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
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
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
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
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
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 textauthor- 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
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
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
Clears all data from the specified sheet- Parameters:
sheetName- The name of the sheet to clear- Returns:
- This SpreadsheetFile instance for method chaining
-
clearCellRange
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
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 rangestartRow- 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
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
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 URLlabel- The optional display label for the hyperlink- Returns:
- This SpreadsheetFile instance for method chaining
-
setCellHyperlink
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 propertiesstartRow- 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
Sets the print orientation for the active sheet- Parameters:
orientation- The orientation ("portrait" or "landscape")- Returns:
- This SpreadsheetFile instance for method chaining
-
setRepeatingColumns
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
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
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
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
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
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
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
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
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
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
String representation of the spreadsheet file
-