BoxLang ๐Ÿš€ A New JVM Dynamic Language Learn More...

BoxLang Spreadsheet

v1.8.0+10 BoxLang Modules

BoxLang Spreadsheet Module ๐Ÿ“Š

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

๐ŸŽฏ Overview

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.

โœจ Key Features

  • โœจ Fluent Method Chaining - Intuitive, readable code
  • ๐Ÿ“Š Multiple Formats - .xls (binary) and .xlsx (XML) support
  • ๐ŸŽจ Rich Formatting - Fonts, colors, borders, alignments
  • ๐Ÿ”ข Formula Support - Set, evaluate, and recalculate formulas
  • ๐Ÿ“ˆ Data Import/Export - JSON, CSV, Query, and Array formats
  • ๐Ÿ–ผ๏ธ Image Embedding - Add images with positioning control
  • ๐Ÿ” Password Protection - Secure spreadsheet files
  • ๐Ÿ“„ Multi-Sheet Support - Create and manage multiple worksheets
  • ๐Ÿš€ High Performance - Built on Apache POI

๐Ÿ“‹ Requirements

  • BoxLang Runtime 1.0.0 or higher
  • BoxLang+ License - This module requires a BoxLang+ license

๐Ÿ“ฆ Installation

Using CommandBox:

box install bx-spreadsheet

๐Ÿš€ Quick Start

Create Your First 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 an Existing Spreadsheet

// 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();

Using Traditional BIF Functions

// 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" );

Using Components

<!-- 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" />

๐Ÿ“– Complete Documentation

For comprehensive documentation including detailed API references, advanced features, and extensive examples, visit the official documentation:

๐Ÿ“š BoxLang Spreadsheet Module Documentation

The official documentation covers:

๐Ÿ”— Additional Resources


๐Ÿ’ก Common Patterns

AI Document Loading with SpreadsheetLoader

Use SpreadsheetLoader when you want to convert spreadsheet data into AI-ready Document objects (for pipelines, memory ingestion, and retrieval workflows).

โ„น๏ธ This loader extends BaseDocumentLoader from the bx-ai module, so bx-ai must be available in your runtime.

import bxModules.bxSpreadsheet.loaders.SpreadsheetLoader;

// One document per sheet (default)
loader = new SpreadsheetLoader( source: "./data/customers.xlsx" );
docs = loader.load();

// One document per data row, with explicit sheet selection
rowDocs = new SpreadsheetLoader( source: "./data/customers.xlsx" )
    .rowsAsDocuments()
    .sheets( [ "Customers" ] )
    .load();

Creating and Formatting

// 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" );

Working with Existing Files

// Load, modify, and save
Spreadsheet( "existing.xlsx" )
    .selectSheet( "Data" )
    .setCellValue( 2, 1, "Updated Value" )
    .setCellFormula( 2, 5, "SUM(B2:D2)" )
    .recalculateAllFormulas()
    .save();

Data Export

// 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

๐Ÿ’ฌ Support & Community


Built with โค๏ธ by Ortus Solutions

Professional Services Available - Need help with BoxLang implementation, training, or consulting? Contact Ortus Solutions

Changelog

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.


Unreleased

1.8.0 - 2026-05-21

Breaking Changes

  • Member method argument order corrected to match BIF conventions. Value/data/format arguments now come before positional row/column arguments. Affected methods:
    • setCellValue(value, row, column) โ€” was (row, column, value)
    • setCellFormula(formula, row, column) โ€” was (row, column, formula)
    • setCellRangeValue(value, startRow, endRow, startColumn, endColumn) โ€” was (value, startRow, startColumn, endRow, endColumn)
    • formatRow(format, row) โ€” was (row, format)
    • formatRows(format, rows) โ€” was (rows, format)
    • formatColumn(format, column) โ€” was (column, format)
    • formatColumns(format, columns) โ€” was (columns, format)
    • formatCell(format, row, column) โ€” was (row, column, format)

Added

  • Bump com.github.pjfanning:excel-streaming-reader from 5.1.2 to 5.2.0
  • All BIF functions now return the SpreadsheetFile object instead of null, enabling fluent method chaining
  • @BoxMember annotations on all BIFs for member method syntax support
  • Declarative argument validation via Validator.min(), Validator.max(), and Validator.NON_EMPTY
  • New SpreadsheetLoader in src/main/bx/loaders/SpreadsheetLoader.bx for BoxLang AI document loading workflows:
    • Loads spreadsheet content as AI Document objects
    • Supports one document per sheet (default) or one document per row (rowsAsDocuments)
    • Supports header-aware row formatting (hasHeaders) and sheet filtering (sheets)
    • Inherits the IDocumentLoader contract via BaseDocumentLoader

Fixed

  • .xls (legacy binary format) support restored โ€” Shadow plugin service file merging was broken

Changed

  • Requires BoxLang 1.13.0+
  • Internal: instanceof pattern variables replace manual casts across all BIFs

1.7.0 - 2026-03-19

1.6.0 - 2026-03-18

1.5.0 - 2026-03-17

1.4.0 - 2026-03-17

1.3.1 - 2026-03-16

1.2.0 - 2026-01-09

1.1.0 - 2025-11-07

Added

  • bx-plus dependency requirement for BoxLang+ subscribers.

1.0.0 - 2025-10-29

  • First Release

$ box install bx-spreadsheet

No collaborators yet.
     
  • {{ getFullDate("2025-10-28T15:36:24Z") }}
  • {{ getFullDate("2026-05-21T13:00:00Z") }}
  • 1,188
  • 4,111