User Guide
Comprehensive guide to using the BoxLang Spreadsheet Module with the Fluent API
This comprehensive guide covers all aspects of working with spreadsheets in BoxLang using the modern Fluent API. The Fluent API provides a chainable, intuitive interface for all spreadsheet operations.
🎯 Core Concepts
The SpreadsheetFile Object
The Fluent API centers around the SpreadsheetFile object, created using the Spreadsheet() function:
// Create new spreadsheet object with a file name
// Or load the file if it exists
sheet = Spreadsheet( "myfile.xlsx" )
// Same as
sheet = Spreadsheet().setPath( "myfile.xlsx" )
// Load existing spreadsheet
sheet = Spreadsheet( "existing.xlsx" )
// Create in-memory spreadsheet
sheet = Spreadsheet();Method Chaining
Most methods return the SpreadsheetFile object, enabling fluent chaining:
Working with Sheets
Every spreadsheet has one or more worksheets. Methods operate on the currently selected sheet:
📝 Creating Spreadsheets
Creating a New File
Setting Cell Values
Adding Rows
Adding Columns
📖 Reading Spreadsheets
Loading Files
Reading Cell Values
Reading Rows and Columns
Converting to Data Structures
Streaming Large Files
For large spreadsheets with thousands of rows, use the process() method to stream data row-by-row without loading the entire file into memory:
Memory Efficient: Streaming keeps only ~100 rows in memory at a time, allowing you to process files with millions of rows. See the Large File Streaming Guide for complete details.
When to use streaming:
Files with > 10,000 rows
Import/export operations
Sequential data processing
Memory-constrained environments
When to use traditional loading:
Files with < 10,000 rows
Random access to rows
Modifying and saving files
Multiple passes over data
🎨 Formatting
Cell Formatting
Row and Column Formatting
Range Formatting
Column Widths
🔢 Working with Formulas
Adding Formulas
Working with Formula Results
Advanced Formulas
📊 Multiple Sheets
Creating and Managing Sheets
Working Across Sheets
🔀 Advanced Operations
Merging Cells
Adding Comments
Hiding Rows and Columns
Freeze Panes
Data Validation
💾 Saving and Exporting
Save Methods
Export Formats
🔧 Utility Operations
Sheet Information
Clearing Content
Deleting Rows and Columns
🎯 Best Practices
1. Use Method Chaining
Good:
Avoid:
2. Format After Adding Data
Add all data first, then apply formatting for better performance:
3. Use Auto-sizing Wisely
Call autoSizeColumns() once after all data is added:
4. Handle Errors Gracefully
5. Close Large Files
For very large files, explicitly clear references:
🔍 Common Patterns
Pattern: Database Export with Formatting
Pattern: Template-Based Reporting
Pattern: Multi-Sheet Workbook
📚 Next Steps
Explore specific topics in detail:
FormattingFormulasData ExportAdvanced FeaturesExamplesComplete API Reference
Fluent APILast updated
Was this helpful?
