Vanilla JS and HTML
If you’re not using a front-end framework, you can still use the API to add spreadsheets to your web app. You can use the TREB library from a CDN or download and use a local copy.
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body><!-- we will add the spreadsheet to this div --><div id='spreadsheet'></div><!-- make sure to use type=module for ES --><script type="module">// load the global instance from the script. here we're using// the unpkg CDN, but you can use a local copy. in that case// point to the file `treb-spreadsheet.mjs`.import { TREB } from "https://unpkg.com/@trebco/treb";// start when the DOM is loadedwindow.addEventListener('DOMContentLoaded', () => {// get a reference to the nodeconst container = document.querySelector('#spreadsheet');// create the spreadsheetconst sheet = TREB.CreateSpreadsheet({container,});// do something with APIsheet.SetRange('B2', '=RAND()');console.info("random value:", sheet.GetRange("B2"));});</script></body></html>
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body><!-- we will add the spreadsheet to this div --><div id='spreadsheet'></div><!-- make sure to use type=module for ES --><script type="module">// load the global instance from the script. here we're using// the unpkg CDN, but you can use a local copy. in that case// point to the file `treb-spreadsheet.mjs`.import { TREB } from "https://unpkg.com/@trebco/treb";// start when the DOM is loadedwindow.addEventListener('DOMContentLoaded', () => {// get a reference to the nodeconst container = document.querySelector('#spreadsheet');// create the spreadsheetconst sheet = TREB.CreateSpreadsheet({container,});// do something with APIsheet.SetRange('B2', '=RAND()');console.info("random value:", sheet.GetRange("B2"));});</script></body></html>