NOTE: this project is quite old. I won't be maintaining it anymore, but it should still work :-)
create spreadsheets with excel-like features
Install with component(1):
$ component install matthewmueller/spreadsheet
Or include the the files in the /dist
folder
var Spreadsheet = require('spreadsheet');
var spreadsheet = Spreadsheet();
document.body.appendChild(spreadsheet.el);
spreadsheet
.select('B1, C1, D1').insert(['Revenues', 'Expenses', 'Profit']).addClass('bold')
.select('A2:A9').insert(years([1, 2, 3, 4, 5, 6, 7, 8])).addClass('bold')
.select('B2:B9').insert([10, 12, 32, 43, 53, 23, 32, 43]).format('$').editable()
.select('C2:C9').insert([32, 11, 22, 33, 45, 42, 10, 32]).format('$').editable()
.select('D2:D9').calc(':B - :C').format('$')
function years(arr) {
return arr.map(function(item) {
return 'Year ' + item;
})
}
Create a new spreadsheet
Create a selection on the spreadsheet. Selections can be a single cell, block, entire row, or an entire column. Selections have their own set of methods
spreadsheet
.select('A1') // Select the cell A1
.select('A1:H9') // Select a block A1 to A9
.select(':2') // Select the entire 2nd row
.select(':A') // Select the entire A column
.select('D4, A10:F3, :3, :C') // Select many
Insert cells into the spreadsheet.
spreadsheet
.select('A1:A9').insert([1, 2, 3, 4, 5, 6]);
Calculate an expr
. Reacts to changes in other cells. Automatically resolves columns and rows.
spreadsheet
.select('A1').calc(':B + :C * 100') // resolves to: A1 = B1 + C1
You can also do a one-off calculation:
spreadsheet
.select('A1').calc('B4 * C9 + 10')
Set the format of the cell. This function current supports:
spreadsheet.select('A1:A9').format('$') // dollar
spreadsheet.select('B1:B9').format('%') // percentages
Set the cells in the selection to be editable
spreadsheet.select('A1:A9').editable()
Add a class to each cell in the selection.
spreadsheet.select('A1:A9').addClass('bold')
MIT