This is a spreadsheet front end written using [Svelte](https://svelte.dev). You need to implement any calculations yourself. You also need to supply a 2D array of cell values & formats along with a config for rows & columns info. The REPL has an example of all that.
Try dbl clicking (or hit Enter/F2) on a cell to edit. Or select some with mouse or keyboard.
The buttons show how easy it is to format a cell or display something other than the raw cell value eg a currency.
allowedActions="EDIT RESIZE FORMAT DELETE COPY PASTE NAVIGATE"
onselchange(selectedCells) - when the user navigates somewhere
startedit(selectedCells) - before the user edits a cell
onendedit(selectedCells) - when the user changes a cells value
Adding more for e.g. row/col resize would be straightforwardNeeds only 3 params - config, data (2D array) and a uid.
Two optional params - title (useful when displaying multiple Tables) and allowedActions (see above) - default is all allowed
defaultGridConfig is the default config. It contains row & column initial configs sizings. It's self explanatory - see utils.js
data[ ][ ] is a 2D array of cell object. Each cell object looks like
let cell = {
value:'', // raw string. Often what is entered by the user.
display:'', // what is displayed often isn't the same as the value. E.G. formulas, 12=>$12.00, -12=>($12.00). It is the parents responsibility to populate this
result:'', // the result of a formula or just the value as a string/number
format:JSON.parse(JSON.stringify(defaultCellFormat)),
};
Each cell has its' own format. The format object looks like -
const defaultCellFormat = {
"italics": 0,
"bold": 0,
"underline":0,
"fontsize": 13,
"align": "left",
"colour": "#888",
"background": "#fff",
"border": [false,false,false,false], // TLBR
"readonly": false,
}
Again, it's self explanatory, and straightforward to extend.
In production uncomment the .focus() in onMount() of Table.svelte. It's highly irritating to keep having the focus ripped away when testing in the REPL.