DownloadjQuery Calx 3.0
<div align="center">

Modern spreadsheet-like calculation engine for the web
Transform your HTML forms into powerful spreadsheet calculators with real-time formula evaluation, cell dependencies, and Excel-compatible functions.
Documentation โข Examples โข Legacy Docs
</div>
โจ Features
-
๐ง TypeScript Rewrite - Complete modern rewrite with improved type safety
-
โก Dynamic Dependencies - Automatic dependency tracking and calculation
-
๐ฐ Input Masking - Built-in formatters (currency, percent, number, etc.)
-
๐จ Conditional Styling - Apply CSS styles based on cell values
-
๐ท๏ธ Named Variables - Use readable names instead of cell addresses
-
๐ Multi-Sheet Support - Work with multiple calculation sheets
-
๐ Auto Addresses - Formula cells get automatic CALX addresses
-
๐ฑ Responsive - Mobile-friendly with modern UI
-
๐งฎ Excel Functions - 400+ Excel-compatible functions via FormulaJS
-
๐ Backward Compatible - Works with jQuery Calx 2.x code
๐ Quick Start
Installation
Via NPM
npm install @xsanisty/calxjs
Via CDN (Coming Soon)
<!-- jQuery (required for plugin) -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- jQuery Calx -->
<script src="https://cdn.jsdelivr.net/npm/@xsanisty/[email protected]/dist/jquery.calx.js"></script>
Basic Example
<form id="calculator">
<input type="number" data-cell="A1" value="10">
<input type="number" data-cell="A2" value="20">
<input type="text" data-formula="A1+A2" readonly>
</form>
<script>
$('#calculator').calx();
</script>
With Formatters
<form id="invoice">
<input data-cell="A1" data-var="PRICE" value="100" data-format="currency">
<input data-cell="A2" data-var="QTY" value="5">
<input data-cell="A3" data-var="TAX" value="0.08" data-format="percent">
<input data-formula="PRICEQTY(1+TAX)" data-format="currency" readonly>
</form>
<script>
$('#invoice').calx({ autoCalculate: true });
</script>
๐ Documentation
๐ก Examples
Explore interactive examples in the examples/ directory:
๐ Usage
jQuery Plugin
// Initialize
$('#form').calx({
autoCalculate: true,
data: {
A1: { value: 100, format: 'currency' }
},
variables: {
TAX: 'A1'
},
functions: {
CUSTOM: function(x) { return x * 2; }
}
});
// Methods
$('#form').calx('getCellValue', 'A1');
$('#form').calx('setCellValue', 'A1', 100);
$('#form').calx('calculate');
TypeScript API
import { Calx } from '@xsanisty/calxjs';
const workbook = Calx.createWorkbook();
const sheet = workbook.createSheet('sheet1');
sheet.mount('#element');
sheet.setCell('A1', 10);
sheet.setCell('A2', 20);
sheet.setCell('A3', '=A1+A2');
sheet.calculate();
console.log(sheet.getCell('A3').value); // 30
๐ง Development
Prerequisites
Setup
# Install dependencies
npm install
# Build both core and jQuery plugin
npm run build
# Run tests
npm test
# Run tests in watch mode
npm test:watch
# Generate coverage report
npm run test:coverage
Build Commands
| Command | Description |
|---------|-------------|
| npm run build | Build both core and jQuery plugin |
| npm run build:core | Build core library only |
| npm run build:jquery | Build jQuery plugin only |
| npm run build-parser | Regenerate formula parser (rarely needed) |
Project Structure
calx.js/
โโโ src/ # TypeScript source
โ โโโ Calx.ts # Main entry point
โ โโโ Calx/ # Core classes
โ โ โโโ Cell.ts
โ โ โโโ Sheet.ts
โ โ โโโ Workbook.ts
โ โ โโโ Formula/ # Formula engine
โ โ โโโ Parser/ # Expression parser
โ โ โโโ Utility/ # Helper functions
โ โโโ jquery.calx.ts # jQuery plugin
โโโ dist/ # Compiled output
โ โโโ calx.js # Core library
โ โโโ jquery.calx.js # jQuery plugin
โโโ examples/ # Live examples
โโโ test/ # Jest tests
โโโ docs/ # Documentation
โโโ legacy/ # jQuery Calx 2.x
๐งช Testing
Currently 209 out of 223 tests passing (93.7%).
# Run all tests
npm test
# Watch mode
npm test:watch
# With coverage
npm run test:coverage
# Performance benchmarks
npm run test:performance
Performance Benchmarks
The test suite includes comprehensive performance tests that measure:
-
Formula Parsing - 1000+ formulas in <2s
-
Calculation Speed - 1000 cells in <1s
-
Dependency Chains - 100-cell chain in <500ms
-
Large Datasets - 10x100 grid (1000 cells) in <3s
-
SUM Ranges - 10 SUMs over 1000 cells in <1s
-
Complex Formulas - Nested IF, SUMIF, mathematical operations
-
Multi-Sheet - Cross-sheet references
-
Real-World Scenarios - Invoice calculations, mortgage amortization
Run npm run test:performance to see detailed timing metrics for your system.
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide for details.
-
Fork the repository
-
Create your feature branch (`git checkout -b feature/amazing-feature`)
-
Commit your changes (`git commit -m 'Add amazing feature'`)
-
Push to the branch (`git push origin feature/amazing-feature`)
-
Open a Pull Request
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
-
Original jQuery Calx 2.x by @xsanisty
-
FormulaJS for Excel function implementations
-
Chevrotain for parser infrastructure
-
All contributors and users of jQuery Calx
๐ Support
<div align="center">
Made with โค๏ธ by Xsanisty
โญ Star us on GitHub โ it helps!
GitHub โข npm
</div>
|