BoxLang ๐ A New JVM Dynamic Language Learn More...
A powerful BoxLang module for creating, reading, and manipulating Excel spreadsheet files.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ          โก B o x L a n g  S p r e a d s h e e t     โ
โ      Dynamic ยท Powerful ยท Production-Ready            โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Copyright Since 2023 by Ortus Solutions, Corp
www.boxlang.io | www.ortussolutions.com
The BoxLang+ Spreadsheet Module
(bx-spreadsheet) is a comprehensive library for Excel
file manipulation in BoxLang. Built on Apache POI, it provides three
distinct APIs to suit different coding styles:
| API Type | Entry Point | Use Case | 
|---|---|---|
| Fluent API โจ | Spreadsheet() | Modern chainable interface (recommended) | 
| BIF Functions ๐ | SpreadsheetNew(),
etc. | Traditional function-based approach | 
| Component Tag ๐ท๏ธ | <bx:spreadsheet> | Declarative CFML-compatible syntax | 
๐ก Recommended: Use the Fluent API (
Spreadsheet()) for the most modern, readable, and maintainable code.
.xls (binary)
and .xlsx (XML) supportThis module requires the
bx-plus module in order to unlock functionality.
Using CommandBox:
box install bx-spreadsheet
// Create a sales report with the fluent API
Spreadsheet( "sales-report.xlsx" )
    .createAndSelectSheet( "Sales Report" )
    .setRowData( 1, [ "Product", "Q1", "Q2", "Q3", "Q4", "Total" ] )
    .addRow( [ "Widget A", 1000, 1200, 1100, 1300, "=SUM(B2:E2)" ] )
    .addRow( [ "Widget B", 800, 900, 950, 1050, "=SUM(B3:E3)" ] )
    .formatRow( 1, { bold: true, fgcolor: "blue", fontColor: "white" } )
    .autoSizeColumns()
    .save();
// Read and convert to different formats
data = Spreadsheet( "sales-data.xlsx" ).toArray();
csvData = Spreadsheet( "report.xlsx" ).toCSV();
jsonData = Spreadsheet( "report.xlsx" ).toJson();
queryData = Spreadsheet( "report.xlsx" ).toQuery();
// Create with BIFs
spreadsheet = SpreadsheetNew( "My Report", true );
SpreadsheetSetCellValue( spreadsheet, "Product", 1, 1 );
SpreadsheetAddRow( spreadsheet, "Widget A,29.99" );
SpreadsheetFormatRow( spreadsheet, { bold: true }, 1 );
SpreadsheetWrite( spreadsheet, "products.xlsx", true );
// Read with BIFs
data = SpreadsheetRead( "products.xlsx" );
<!-- Create and populate -->
<bx:spreadsheet action="create" name="mySheet" sheetname="Report" />
<bx:spreadsheet action="setCellValue" name="#mySheet#" row="1" column="1" value="Name" />
<bx:spreadsheet action="addRow" name="#mySheet#" data="#['John Doe', 'Engineer']#" />
<bx:spreadsheet action="write" name="#mySheet#" filename="output.xlsx" overwrite="true" />
For comprehensive documentation including detailed API references, advanced features, and extensive examples, visit the official documentation:
The official documentation covers:
// Fluent API with chaining
Spreadsheet()
    .createAndSelectSheet( "Report" )
    .setRowData( 1, [ "Name", "Age", "Salary" ] )
    .addRow( [ "John Doe", 30, 50000 ] )
    .formatRow( 1, { bold: true, fgcolor: "blue" } )
    .autoSizeColumns()
    .save( "output.xlsx" );
// Load, modify, and save
Spreadsheet( "existing.xlsx" )
    .selectSheet( "Data" )
    .setCellValue( 2, 1, "Updated Value" )
    .setCellFormula( 2, 5, "SUM(B2:D2)" )
    .recalculateAllFormulas()
    .save();
// Export to multiple formats
sheet = Spreadsheet( "data.xlsx" );
arrayData = sheet.toArray();         // Array of structs
queryData = sheet.toQuery();         // Query object
jsonData = sheet.toJson( true );     // Pretty JSON string
csvData = sheet.toCSV();             // CSV string
Professional Services Available - Need help with BoxLang implementation, training, or consulting? Contact Ortus Solutions
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
								$ 
									box install bx-spreadsheet