跳到正文
GitHub·· 7 天前AI 评分22

osbxl 官方代码示例库发布:AI 就绪的 C++ 表格计算引擎

osb-office/osbxl-samples

AI 导读

osbxl 官方代码示例库 osbxl-samples 上线,为这款 AI 就绪的 C++ 表格计算与 Excel 生成引擎提供 Python、Node.js、Java、PHP、WebAssembly 五种语言的示例代码。

正文

🇯🇵 日本語版の README はこちら (README.ja.md)

Official verified code samples and patterns for osbxl (https://osb-office.com) — an AI-ready, ultra-fast C++ core multi-platform spreadsheet calculation and Excel generation engine.

Official Website Library Comparison AI-Ready Languages


📊 Comparison with Popular Excel Libraries

For in-depth analysis and migration tips, check out our Online Library Comparison Guide.

Pure high-level libraries (Apache POI, openpyxl, PhpSpreadsheet) often suffer from Out of Memory errors, GC pauses, and absent formula calculation engines on large datasets. osbxl’s optimized C++ core eliminates these bottlenecks:

Feature / Metric osbxl Apache POI (Java) openpyxl (Python) PhpSpreadsheet (PHP) SheetJS / ExcelJS (JS)
Core Engine Native C++ Java Python PHP JavaScript
Large-Scale Data Speed ◎ Blazing Fast ◯ (Streaming SXSSF) △ (Slow on large sheets) ✕ (Severely slow) ◯ / △
Memory Footprint ◎ Ultra-low (Up to 90% less) △ (High heap usage) △ (Object overhead) ✕ (Frequent 500 crashes) △ (V8 heap limit)
Formula Calculation ~500 functions (XLOOKUP etc.) 300–400 functions ✕ (Cannot evaluate) △ (Partial & heavy) Limited / Paid add-on
AI Code Generation ◎ Official Skill Included None (High hallucination) None None None
WebAssembly ◎ Native Support (Wasm 3.0) ✕ △ (Huge Pyodide runtime) ✕ ◯

🌟 Key Features

  • 🤖 AI-Ready with Zero Hallucinations: Bundled with official AI Skill packages tailored for Cursor, GitHub Copilot, Gemini, and Claude Code. AI generates verified, runnable Excel manipulation code on the first try.
  • ⚡ Overwhelming C++ Speed: Native C++ core engine processes large workbooks and complex formula calculations in milliseconds with minimal memory footprint.
  • 🌐 5 Supported Platforms: Consistent, clean APIs across Python (pyosbxl), Node.js (nodeosbxl), Java (osbxl), PHP (phposbxl), and WebAssembly (wasmosbxl).
  • 📊 Rich Spreadsheet Capabilities: Nearly 500 Excel-compatible functions, charts (bar, line, etc.), AutoFilters, Tables (ListObjects), Conditional Formatting, and PivotTables.
  • 🔒 Security: Read and write password-protected, encrypted .xlsx workbooks.

📁 Repository Structure

osbxl-samples/
├── README.md               # Overview and quick reference
├── README.ja.md            # 日本語版 README
├── LICENSE                 # Licenses (MIT for samples, OSBXL agreement for engine)
├── LICENSE.ja.md           # 日本語版ライセンス条項
├── examples/               # Standalone runnable code examples
│   ├── python/             # Python samples
│   │   ├── quickstart.py             # Basic workbook creation & formulas
│   │   ├── chart_sample.py           # Column & line charts creation
│   │   ├── table_comments_sample.py  # Tables (ListObjects) & threaded comments
│   │   └── conditional_format_sample.py # Conditional formatting & data bars
│   ├── nodejs/             # Node.js samples
│   │   ├── quickstart.js             # Basic workbook creation & formulas
│   │   ├── chart_sample.js           # Column & line charts creation
│   │   └── table_comments_sample.js  # Tables (ListObjects) & threaded comments
│   ├── java/               # Java sample (QuickStart.java)
│   ├── php/                # PHP sample (quickstart.php)
│   └── wasm/               # WebAssembly sample (quickstart.wat, quickstart.wasm.js)
├── ja/                     # 日本語版 Web 形式リファレンス (general-01 ~ 11)
└── en/                     # English Web Reference (general-01 ~ 11)

📊 Feature Comparison Matrix & Real-world Benchmarks

A side-by-side comparison of advanced features (formula engine, PivotTables, charts, password encryption) and measured performance between popular open-source libraries and osbxl.

1. Feature Support Matrix

Feature osbxl (5 Languages) Apache POI (Java) openpyxl (Python) PhpSpreadsheet (PHP) ExcelJS / SheetJS (JS)
.xlsx Read & Write ◎ Fast & Stable ◎ ◎ ◎ ◎
Headless Formula Calculation
(Evaluating values without Excel)
◎ ~500 Functions
(XLOOKUP, VLOOKUP, etc.)
◯ 300–400 Functions
(Evaluator)
✕ Not Supported
(None until Excel opens)
△ Partial
(Heavy & limited)
✕ Not Supported
(Requires paid SheetJS Pro)
Tables & Structured References
(e.g. SUM(Table[Column]))
◎ Full Native Eval △ No Calculation
(Save only)
✕ Cannot Eval ✕ Cannot Eval ✕ Cannot Eval
AutoFilter ◎ Advanced Filter ◯ ◯ ◯ ◯
PivotTable Creation ◎ Standard API ◯ Low-level XML △ Read-focused ✕ Not Supported ✕ Not Supported
Chart & Graph Generation ◎ 2D & 3D Charts ◯ Via XDDF ◯ 2D/3D Support △ Limited rendering ✕–△ Minimal
Password Encryption / Decryption ◎ Built-in ◯ Standard ✕ Needs 3rd-party tool ✕ Needs extension ✕ Not Supported
Cell Comments (Notes & Threads) ◎ Both Notes & Threads ◯ Notes only ◯ Comments only ◯ Comments only ◯ Comments only
AI Codegen Optimization ◎ Official AI Skill
(Zero hallucination)
✕ Unofficial
(Frequent fake APIs)
✕ Unofficial ✕ Unofficial ✕ Unofficial

2. Standard 200-Row (800-Cell) Benchmark

Measured under the same development environment (Linux x86_64) generating a standard business report (200 rows × 4 columns = 800 cells + SUM formula).

Language Library Time (sec) Memory (MB) Highlights
Java (JDK 1.8) Apache POI 5.2.5 (XSSF)
osbxl (Java)
0.622 s
0.139 s
15.19 MB
16.87 MB
osbxl is ~4.5x faster.
POI carries heavy XML schema init overhead; osbxl starts and finishes instantly.
Node.js (v24) ExcelJS 4.4.0
nodeosbxl
0.059 s
0.054 s
113.48 MB
132.02 MB
nodeosbxl is slightly faster (0.05s range).
Native C++ calculation engine included with no performance penalty.
Python (3.14) openpyxl 3.1.5
pyosbxl
0.019 s
0.052 s
53.57 MB
77.81 MB
openpyxl is fast but cannot calculate formulas.
pyosbxl completes full native calculation & output in 0.05s.
PHP (8.5) PhpSpreadsheet 5.10.0
phposbxl
0.117 s
0.122 s
26.00 MB
2.00 MB
Similar speed, but phposbxl uses 13x less memory (only 2 MB).
Critical advantage under concurrent web downloads.

3. Large-Scale 50,000-Row (200,000 Cells) Stress Test

Stress test results scaling data up to 50,000 rows × 4 columns = 200,000 cells + SUM formula. While popular open-source libraries crash from out-of-memory errors, osbxl completes cleanly across all platforms.

Runtime / Limits Library Execution Time Memory Usage Highlights & Fault Analysis
PHP (8.5 / 128M) PhpSpreadsheet 5.10.0
phposbxl
✕ Crashed
8.329 s
✕ OOM (>128MB limit)
22.01 MB
PhpSpreadsheet crashes fatally (Allowed memory size exhausted).
phposbxl runs safely using only 22 MB (generating a 1.93 MB .xlsx).
Java (JDK 1.8 / 256M) Apache POI 5.2.5 (XSSF)
osbxl (Java)
✕ Crashed
15.740 s
✕ OOM (>256MB heap)
42.13 MB
POI crashes fatally (OutOfMemoryError: Java heap space).
osbxl finishes cleanly within 42 MB without requiring rewriting to restricted SXSSF streaming mode.
Node.js (v24) ExcelJS 4.4.0
nodeosbxl
1.379 s
7.836 s
864.66 MB
1,060 MB
(*Node heap is only 31MB)
ExcelJS outputs XML fast but lacks a formula calculation engine.
nodeosbxl evaluates and populates all formulas natively (resolving dependency graphs).
Python (3.14) openpyxl 3.1.5
pyosbxl
2.529 s
8.049 s
299.72 MB
964 MB
openpyxl is fast but formula results evaluate to None in headless environments.
pyosbxl retains evaluated formula values natively.

📖 Full Feature Matrix & Detailed Analysis: See Excel Library Feature Comparison & Benchmark Report (en/benchmark-comparison.md). *Note: nodeosbxl and pyosbxl allocate ~950–1,000 MB RSS because they construct a full native formula dependency graph for headless calculation across ~500 functions (Node.js runtime heap is only 31 MB). This differs fundamentally from pure stream serializers like ExcelJS or openpyxl, which perform no formula evaluation.


🚀 Quick Code Examples

Python (pyosbxl)

import pyosbxl

app = pyosbxl.App()
book = app.createWorkBook("sales_report.xlsx")
sheet = book.addWorkSheet("Sales")

sheet.getRange("A1").setValue("Monthly Sales")
sheet.getRange("A2").setValue(150000)
sheet.getRange("A3").setValue(230000)
sheet.getRange("A4").setFormula("SUM(A2:A3)")

book.save()
book.close()

Node.js (nodeosbxl)

const osbxl = require("nodeosbxl");

const app = new osbxl.App();
const book = app.createWorkBook("report.xlsx");
const sheet = book.addWorkSheet("Sheet1");

sheet.getRange("A1").setNumberValue(100);
sheet.getRange("A2").setNumberValue(200);
sheet.getRange("A3").setFormula("SUM(A1:A2)");

book.save();
book.close();

🔗 Official Links & Documentation


📄 License

  • Sample Code & AI Skills: MIT License — Feel free to use, copy, and modify in your projects.
  • OSBXL Engine (Libraries): Commercial / Proprietary by osb-office.inc. See LICENSE or LICENSE.ja.md for software license agreement details.

来源:GitHub · github.com