Examples
Real-world examples and complete code samples for common spreadsheet tasks
Real-world examples demonstrating common spreadsheet tasks using the BoxLang Fluent API. Copy and adapt these patterns for your own projects.
📊 Report Generation
Monthly Sales Report
// Query sales data
sales = queryExecute("
SELECT
product_name,
SUM(quantity) as units_sold,
SUM(total_amount) as revenue,
COUNT(DISTINCT order_id) as orders
FROM sales
WHERE MONTH(sale_date) = MONTH(CURRENT_DATE)
GROUP BY product_name
ORDER BY revenue DESC
");
// Create report
Spreadsheet( "monthly-sales-#month(now())#-#year(now())#.xlsx" )
// Title
.setCellValue( 1, 1, "Monthly Sales Report" )
.mergeCells( 1, 1, 1, 4 )
.formatCell( 1, 1, {
bold: true,
fontsize: 16,
alignment: "center",
fgcolor: "darkblue",
fontColor: "white"
} )
.setRowHeight( 1, 25 )
// Report date
.setCellValue( 2, 1, "Report Date:" )
.setCellValue( 2, 2, dateFormat( now(), "mmmm dd, yyyy" ) )
.formatRow( 2, { italic: true } )
// Headers
.setRowData( 4, [ "Product", "Units Sold", "Revenue", "Orders" ] )
.formatRow( 4, {
bold: true,
fgcolor: "lightblue",
alignment: "center"
} )
// Data
.addRows( sales, startRow = 5 )
// Totals
.setRowData( sales.recordCount + 5, [
"TOTAL",
"=SUM(B5:B#sales.recordCount + 4#)",
"=SUM(C5:C#sales.recordCount + 4#)",
"=SUM(D5:D#sales.recordCount + 4#)"
] )
.formatRow( sales.recordCount + 5, {
bold: true,
fgcolor: "lightgray",
topborder: "double"
} )
// Format columns
.formatColumn( 2, { dataformat: "#,##0", alignment: "right" } )
.formatColumn( 3, { dataformat: "$#,##0.00", alignment: "right" } )
.formatColumn( 4, { dataformat: "#,##0", alignment: "right" } )
// Auto-size and freeze header
.autoSizeColumns()
.addFreezePane( 0, 4 )
.save();Financial Statement
📈 Data Analysis
Sales Trend Analysis
Customer Segmentation
📋 Inventory Management
Stock Level Report
👥 HR & Employee Management
Employee Directory
Payroll Summary
🎓 Education
Grade Book
🛒 E-commerce
Order Export
🏥 Healthcare
Patient Appointment Schedule
📚 Next Steps
Now that you've seen practical examples, explore the complete API reference:
Fluent APIBuilt-In FunctionsComponentsLast updated
Was this helpful?
