### Install Dependencies and Start Server Source: https://docs.sheetjs.com/docs/demos/frontend/svelte Installs the SheetJS library and starts the development server. ```bash cd sheetjs-svelte npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### Install Dependencies and Start Server Source: https://docs.sheetjs.com/docs/demos/frontend/openui5 Commands to install project dependencies and launch the local development server. ```bash cd sheetjs.openui5 npm install npm start ``` -------------------------------- ### Setup NodeJS Demo Project Source: https://docs.sheetjs.com/docs/demos/frontend/bundler/systemjs Commands to initialize a project, install dependencies, and run the demo. ```bash mkdir sheetjs-systemjs cd sheetjs-systemjs npm init -y ``` ```bash npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz systemjs@6.15.1 ``` ```bash curl -LO https://docs.sheetjs.com/systemjs/SheetJSystem.js ``` ```bash node SheetJSystem.js ``` -------------------------------- ### Install SheetJS and Start Watch Server Source: https://docs.sheetjs.com/docs/demos/extensions/vscode Navigate to the extension directory, install the SheetJS library from a CDN, and start the development server to watch for file changes. ```bash cd sheetjs-demo pnpm install -D https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz pnpm run watch ``` -------------------------------- ### Project Setup and Dependencies Source: https://docs.sheetjs.com/docs/demos/data/postgresql Create a new project directory, initialize it with npm, and install the 'pg' connector module version 8.13.1. ```bash mkdir sheetjs-pg cd sheetjs-pg npm init -y ``` ```bash npm i --save pg@8.13.1 ``` -------------------------------- ### Install SheetJS and Start Dev Server Source: https://docs.sheetjs.com/docs/demos/extensions/chromium Download a logo, install the SheetJS library from the CDN, and start the development server to build and test your extension. ```bash curl -o ./public/img/logo-48.png https://docs.sheetjs.com/logo.png npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### React Native Project Setup Source: https://docs.sheetjs.com/docs/getting-started/examples/export This example shows the initial setup for a React Native project using SheetJS. It involves creating a new project with a specific CLI version and installing SheetJS along with react-native-blob-util. Follow the environment setup guide for React Native before proceeding. ```bash npx -y @react-native-community/cli@15 init SheetJSPres --version="0.76.5" cd SheetJSPres npm i -S https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz react-native-blob-util@0.21.2 ``` -------------------------------- ### Install Dependencies and Start Dev Server Source: https://docs.sheetjs.com/docs/demos/frontend/angular Navigates into the project directory, installs npm packages, adds the SheetJS dependency from a CDN, disables analytics, and starts the development server. ```bash cd sheetjs-angular npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npx @angular/cli analytics disable npm start ``` -------------------------------- ### Server Start Output Source: https://docs.sheetjs.com/docs/demos/net/server/hono Example output when the BunJS development server starts, indicating the address it is listening on. ```bash % bun run dev $ bun run --hot src/index.ts Started server http://localhost:3000 ``` -------------------------------- ### Install Dependencies and Start Dev Server Source: https://docs.sheetjs.com/docs/demos/frontend/svelte Install SheetJS from a CDN and start the development server for a Svelte project. This prepares the project for local testing. ```bash cd sheetjs-svelte npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### Start MongoDB Server with Homebrew Source: https://docs.sheetjs.com/docs/demos/data/mongodb Starts a MongoDB server instance when installed via Homebrew. ```bash $(brew --prefix)/opt/mongodb-community/bin/mongod --config $(brew --prefix)/etc/mongod.conf ``` -------------------------------- ### Setup Create React App Project Source: https://docs.sheetjs.com/docs/demos/frontend/react Commands to initialize a CRA project and install the SheetJS dependency. ```bash npx -y create-react-app@5.1.0 sheetjs-react ``` ```bash cd sheetjs-react npm i npm i react@19.1.0 react-dom@19.1.0 web-vitals --save --save-exact npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm start ``` ```bash npm run build ``` ```bash npx -y http-server build ``` -------------------------------- ### Setup NextJS Project Source: https://docs.sheetjs.com/docs/demos/frontend/react Commands to initialize a NextJS project and install the SheetJS dependency. ```bash npx next telemetry disable ``` ```bash npx create-next-app@latest sheetjs-nextjs --ts --no-eslint --no-tailwind --no-src-dir --no-app --import-alias "@/*" --no-turbopack ``` ```bash cd sheetjs-nextjs npm i npx next telemetry disable npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### Download Example Script Source: https://docs.sheetjs.com/docs/demos/net/server/drash Command to download the complete example server script. ```bash curl -LO https://docs.sheetjs.com/drash/SheetJSDrash.ts ``` -------------------------------- ### Create Project Folder (Windows) Source: https://docs.sheetjs.com/docs/demos/engines/quickjs Creates a new directory for the SheetJS QuickJS project and navigates into it. This is the initial setup step for the Windows example. ```bash mkdir sheetjs-quick cd sheetjs-quick ``` -------------------------------- ### Setup ViteJS Project Source: https://docs.sheetjs.com/docs/demos/frontend/react Commands to initialize a Vite project and install the SheetJS dependency. ```bash npm create vite@latest sheetjs-react -- --template react --no-rolldown --no-interactive ``` ```bash cd sheetjs-react npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` ```bash npm run build ``` ```bash npx -y http-server dist ``` -------------------------------- ### ViteJS Project Setup for SheetJS React Source: https://docs.sheetjs.com/docs/demos/frontend/react Commands to create a new ViteJS React project, install SheetJS, and run the development server. Replace `src/App.jsx` with the provided `SheetJSReactHTML.js` example. ```bash npm create vite@latest sheetjs-react -- --template react --no-rolldown --no-interactive cd sheetjs-react npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### Initialize project Source: https://docs.sheetjs.com/docs/demos/frontend/bundler/rollup Create a new directory and initialize a package.json file. ```bash mkdir sheetjs-rollup cd sheetjs-rollup npm init -y ``` -------------------------------- ### Create React App Setup for SheetJS React Source: https://docs.sheetjs.com/docs/demos/frontend/react Commands to create a new Create React App project, install SheetJS, and run the development server. Replace `src/App.js` with the provided `SheetJSReactHTML.js` example. ```bash npx -y create-react-app@5.1.0 sheetjs-react cd sheetjs-react npm i npm i react@19.1.0 react-dom@19.1.0 web-vitals --save --save-exact npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm start ``` -------------------------------- ### Complete ElysiaJS and SheetJS Server Example Source: https://docs.sheetjs.com/docs/demos/net/server/elysia A comprehensive server script combining GET and POST request handlers for spreadsheet operations. It includes setup for reading uploaded files and generating downloadable XLSX files. ```typescript import { Elysia, t } from "elysia"; import { read, utils, write } from "xlsx"; const app = new Elysia(); app.get("/", () => { var ws = utils.aoa_to_sheet(["SheetJS".split(""), [5,4,3,3,7,9,5]]); var wb = utils.book_new(); utils.book_append_sheet(wb, ws, "Data"); /* generate buffer */ var buf = write(wb, {type: "buffer", bookType: "xlsx"}); return new File([buf], "SheetJSElysia.xlsx"); /* set headers */ }); app.post("/", async({ body: { upload } }) => { const data = await upload.arrayBuffer(); const wb = read(data); return utils.sheet_to_csv(wb.Sheets[wb.SheetNames[0]]); }, { body: t.Object({ upload: t.File() }) }); app.listen(3000, () => { console.log("SheetJS ElysiaJS server is up")}); ``` -------------------------------- ### Build and Serve Project Source: https://docs.sheetjs.com/docs/demos/frontend/bundler Commands to build the project for production and start a local server. ```bash npx snowpack@3.8.8 build ``` ```bash npx -y http-server build/ ``` -------------------------------- ### Compile and Run hello-world Example (Intel Mac/Linux x64) Source: https://docs.sheetjs.com/docs/demos/engines/v8 Compile the `hello-world` sample using g++ with specific V8 flags and link against `v8_monolith`. Ensure Foundation framework is linked for macOS. ```bash g++ -I. -Iinclude samples/hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -ldl -Lout.gn/x64.release.sample/obj/ -pthread \ -std=c++20 -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX -framework Foundation ``` ```bash ./hello_world ``` -------------------------------- ### Create NodeJS Project and Install Dependencies Source: https://docs.sheetjs.com/docs/demos/cloud/aws Sets up a new NodeJS project and installs the SheetJS library and AWS SDK. Ensure you have NodeJS and npm installed. ```bash mkdir SheetJSS3 cd SheetJSS3 npm init -y ``` ```bash mkdir -p node_modules npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz aws-sdk@2.1692.0 ``` -------------------------------- ### Download Java Example Source: https://docs.sheetjs.com/docs/demos/engines/nashorn Downloads the SheetJSNashorn.java example file. ```bash curl -LO https://docs.sheetjs.com/nashorn/SheetJSNashorn.java ``` -------------------------------- ### Start Android Emulator Source: https://docs.sheetjs.com/docs/demos/mobile/reactnative Launch the Android emulator or start the development server. ```bash npx react-native run-android ``` ```bash npx react-native start ``` -------------------------------- ### BunJS Demo Setup Commands Source: https://docs.sheetjs.com/docs/demos/data/sqlite Commands to prepare the environment and run the BunJS SQLite demo. ```bash curl -LO https://docs.sheetjs.com/sqlite/chinook.sql sqlite3 chinook.db ".read chinook.sql" ``` ```bash bun install https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz ``` ```bash curl -LO https://docs.sheetjs.com/sqlite/SheetJSQLiteBun.mjs ``` ```bash bun run SheetJSQLiteBun.mjs ``` -------------------------------- ### Create Project Directory Source: https://docs.sheetjs.com/docs/demos/engines/jerryscript Creates a new directory for the project and navigates into it. This is the initial setup step. ```bash mkdir SheetJSJerry cd SheetJSJerry ``` -------------------------------- ### Copy sample source Source: https://docs.sheetjs.com/docs/demos/engines/v8 Copy the hello-world source file into the project directory. ```bash cp ~/dev/v8/v8/samples/hello-world.cc . ``` ```cmd copy C:\v8\v8\samples\hello-world.cc .\ ``` -------------------------------- ### Start Colima Process Source: https://docs.sheetjs.com/docs/demos/data/mongodb Starts the Colima process, which is required for Docker Compose installation. ```bash $(brew --prefix)/opt/colima/bin/colima start -f ``` -------------------------------- ### Initialize Project with npm Source: https://docs.sheetjs.com/docs/demos/cloud/gsheet Use these commands to create a new project directory, navigate into it, and initialize a new Node.js project with npm. ```bash mkdir SheetJSGS cd SheetJSGS npm init -y ``` -------------------------------- ### Install PostgreSQL on macOS Source: https://docs.sheetjs.com/docs/demos/data/postgresql Use Homebrew to install the PostgreSQL formula. The output of the installer will provide instructions on how to start the database service. ```bash brew install postgresql@16 ``` ```bash LC_ALL="C" /usr/local/opt/postgresql@16/bin/postgres -D /usr/local/var/postgresql@16 ``` -------------------------------- ### Deno Demo Setup Commands Source: https://docs.sheetjs.com/docs/demos/data/sqlite Commands to prepare the environment and run the Deno SQLite demo. ```bash curl -LO https://docs.sheetjs.com/sqlite/chinook.sql sqlite3 chinook.db ".read chinook.sql" ``` ```bash curl -LO https://docs.sheetjs.com/sqlite/SheetJSQLiteDeno.ts ``` ```bash deno run --allow-read --allow-write SheetJSQLiteDeno.ts ``` ```bash deno run --allow-read --allow-write --allow-import SheetJSQLiteDeno.ts ``` -------------------------------- ### Install and Run NW.js Source: https://docs.sheetjs.com/docs/getting-started/examples/import Commands to install dependencies and launch the NW.js application. ```bash npm i npx nw . ``` -------------------------------- ### Initialize New Project with npm Source: https://docs.sheetjs.com/docs/demos/frontend/bundler/webpack Use these commands to create a new project directory and initialize it with npm. ```bash mkdir sheetjs-webpack cd sheetjs-webpack npm init -y ``` -------------------------------- ### Start Development Server Source: https://docs.sheetjs.com/docs/demos/grid/gdg Run the development server to preview your application. This command compiles the project and starts a local server, typically accessible via a URL like http://localhost:5173. ```bash npm run dev ``` -------------------------------- ### Install SheetJS and Knex.js with better-sqlite3 Source: https://docs.sheetjs.com/docs/demos/data/knex Install SheetJS and Knex.js with the better-sqlite3 driver. This is the recommended setup for newer versions of Knex.js. ```bash npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz knex better-sqlite3 ``` -------------------------------- ### Initialize Lambda Project Source: https://docs.sheetjs.com/docs/demos/cloud/aws Commands to create the project directory and download the necessary files. ```bash mkdir -p SheetJSLambda cd SheetJSLambda ``` ```bash curl -LO https://docs.sheetjs.com/aws/index.js ``` -------------------------------- ### Start MariaDB Server Source: https://docs.sheetjs.com/docs/demos/data/mariadb This command starts a local MariaDB instance using `mysqld_safe`. Ensure the datadir path is correct for your installation. ```bash /usr/local/opt/mariadb/bin/mysqld_safe --datadir=/usr/local/var/mysql ``` -------------------------------- ### Install Dependencies Source: https://docs.sheetjs.com/docs/demos/net/email Initialize the project and install the required SheetJS and nodemailer packages. ```bash mkdir sheetjs-send cd sheetjs-send npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz nodemailer@6.9.12 ``` -------------------------------- ### Install PostgreSQL on Linux Source: https://docs.sheetjs.com/docs/demos/data/postgresql Install PostgreSQL on Debian/Ubuntu systems by adding the PostgreSQL apt repository and then installing the postgresql-16 package. Includes steps for starting the service and optionally creating a user with a password. ```bash echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update sudo apt install postgresql-16 sudo systemctl start postgresql # Optional: Create user with password sudo -u postgres createuser -P $USER sudo -u postgres psql -c "ALTER USER $USER WITH SUPERUSER;" ``` -------------------------------- ### Start Development Server Source: https://docs.sheetjs.com/docs/demos/extensions/excelapi Navigate to the project directory and start the development server. This command builds the project and launches Excel with the add-in. ```bash cd SheetJSImport npm run build npm start ``` -------------------------------- ### Install SheetJS and HappyDOM via npm Source: https://docs.sheetjs.com/docs/demos/net/dom Command to install SheetJS and HappyDOM libraries using npm. This is a prerequisite for running the HappyDOM example. ```bash npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz happy-dom@13.3.1 ``` -------------------------------- ### Initialize Project and Install ESBuild Source: https://docs.sheetjs.com/docs/demos/static/esbuild Create a new directory and initialize a Node.js project with the specified ESBuild version. ```bash mkdir sheetjs-esb cd sheetjs-esb npm init -y npm i --save esbuild@0.20.2 ``` -------------------------------- ### Start Valkey Server Source: https://docs.sheetjs.com/docs/demos/data/redis Starts the Valkey server process using its configuration file. ```bash redis-server $(brew --prefix)/etc/redis.conf ``` -------------------------------- ### Install SheetJS and JSDOM via npm Source: https://docs.sheetjs.com/docs/demos/net/dom Command to install SheetJS and JSDOM libraries using npm. This is a prerequisite for running the JSDOM example. ```bash npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz jsdom@24.0.0 ``` -------------------------------- ### NodeJS/NPM Timeout Error Example Source: https://docs.sheetjs.com/docs/miscellany/errors This is an example of a timeout error that can occur during NodeJS/NPM package installation. Ensure your network connection is stable or consider vendoring the module. ```bash  WARN  GET https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz error (ERR_SOCKET_TIMEOUT). Will retry in 10 seconds. 2 retries left. ``` -------------------------------- ### NodeJS Demo Setup Commands Source: https://docs.sheetjs.com/docs/demos/data/sqlite Commands to prepare the environment and run the NodeJS SQLite demo. ```bash curl -LO https://docs.sheetjs.com/sqlite/chinook.sql sqlite3 chinook.db ".read chinook.sql" ``` ```bash npm init -y npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz better-sqlite3@12.6.2 ``` ```bash curl -LO https://docs.sheetjs.com/sqlite/SheetJSQLiteNode.mjs ``` ```bash node SheetJSQLiteNode.mjs ``` -------------------------------- ### Get First Presidential Term Start Date Source: https://docs.sheetjs.com/docs/getting-started/examples/export Retrieves the 'start' date from the first presidential term of a given president. It relies on the `first_prez_term` function to find the relevant term. ```javascript const first_prez_term_start = prez => first_prez_term(prez).start; ``` -------------------------------- ### Create and Configure a New .NET Console Project Source: https://docs.sheetjs.com/docs/demos/engines/v8 Create a new .NET console project, navigate into its directory, and run the initial project setup. This prepares the environment for adding ClearScript. ```bash mkdir SheetJSClearScript cd SheetJSClearScript dotnet new console dotnet run ``` -------------------------------- ### Start Test Server Source: https://docs.sheetjs.com/docs/miscellany/contributing Initiate a local HTTP server for testing the library in web browsers. ```bash make ctestserv ``` -------------------------------- ### Fetch Example Data File Source: https://docs.sheetjs.com/docs/demos/static/astro Download the 'pres.numbers' example file into the 'src/data' directory. ```bash mkdir -p src/data curl -Lo src/data/pres.numbers https://docs.sheetjs.com/pres.numbers ``` -------------------------------- ### Initialize Project Structure Source: https://docs.sheetjs.com/docs/demos/static/nextjs Commands to create the project directory and required subfolders. ```bash mkdir sheetjs-next cd sheetjs-next npm init -y mkdir -p pages/sheets/ ``` -------------------------------- ### Handle CocoaPods Errors on Windows Source: https://docs.sheetjs.com/docs/demos/mobile/reactnative Example of expected error output when running Expo installation commands on Windows. ```text Uncaught Error CocoaPodsError: Command `pod install` failed. └─ Cause: spawn pod ENOENT 'pod' is not recognized as an internal or external command, operable program or batch file. ``` -------------------------------- ### Initialize Project and Install mysql2 Source: https://docs.sheetjs.com/docs/demos/data/mariadb These commands set up a new project directory, initialize it with npm, and install the `mysql2` connector module, which is required for interacting with MariaDB. ```bash mkdir sheetjs-mariadb cd sheetjs-mariadb npm init -y npm i --save mysql2@3.6.5 ``` -------------------------------- ### Compile and Run hello-world Example (ARM64 Mac/Linux ARM) Source: https://docs.sheetjs.com/docs/demos/engines/v8 Compile the `hello-world` sample for ARM64 architectures using g++ with appropriate V8 flags and link against `v8_monolith`. Link Foundation framework for macOS. ```bash g++ -I. -Iinclude samples/hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -ldl -Lout.gn/arm64.release.sample/obj/ -pthread \ -std=c++20 -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX -framework Foundation ``` ```bash ./hello_world ``` -------------------------------- ### Complete Example: ExpressJS Server with SheetJS Source: https://docs.sheetjs.com/docs/demos/net/server/express A complete ExpressJS server example that handles both file uploads for parsing (POST to /upload) and generating downloadable spreadsheets (GET to /download). It includes necessary middleware and SheetJS integration. ```javascript var XLSX = require('xlsx'), express = require('express'); /* create app */ var app = express(); /* add express-formidable middleware */ app.use(require('express-formidable')()); /* route for handling uploaded data */ app.post('/upload', function(req, res) { var f = req.files["upload"]; // var wb = XLSX.readFile(f.path); /* respond with CSV data from the first sheet */ res.status(200).end(XLSX.utils.sheet_to_csv(wb.Sheets[wb.SheetNames[0]])); }); app.get('/download', function(req, res) { /* generate workbook object */ var ws = XLSX.utils.aoa_to_sheet(["SheetJS".split(""), [5,4,3,3,7,9,5]]); var wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "Data"); /* generate buffer */ var buf = XLSX.write(wb, {type: "buffer", bookType: "xlsx"}); /* set headers */ res.attachment("SheetJSExpress.xlsx"); /* respond with file data */ res.status(200).end(buf); }); app.listen(+process.env.PORT||3000, function() { console.log("Ready to go"); }); ``` -------------------------------- ### Start Local Web Server Source: https://docs.sheetjs.com/docs/demos/data/pouchdb Start a local web server in the project directory to serve the application. Access the application via the provided URL in a web browser. ```bash npx -y http-server . ``` -------------------------------- ### Create NuxtJS Site Source: https://docs.sheetjs.com/docs/demos/frontend/vue Instructions for initializing a new Nuxt.js project with npm, installing SheetJS, and starting the development server. ```bash npx nuxi@latest init sheetjs-nuxt --packageManager npm --no-install --no-gitInit -M , npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### Create Go Module and Install Dependencies Source: https://docs.sheetjs.com/docs/demos/engines/goja Initializes a new Go module and installs the necessary goja dependency. This is the first step in setting up the project. ```Shell mkdir SheetGoja cd SheetGoja go mod init SheetGoja go get github.com/dop251/goja ``` -------------------------------- ### Complete SheetJS and axios Upload Example Source: https://docs.sheetjs.com/docs/demos/net/upload A comprehensive example demonstrating how to create a SheetJS workbook, export it to an array buffer, package it into FormData, and upload it using axios. This snippet includes all necessary SheetJS utility functions and axios request setup. ```javascript /* create sample SheetJS workbook object */ var aoa = [ ["S", "h", "e", "e", "t", "J", "S"], [ 5, 4, 3, 3, 7, 9, 5] ]; const ws = XLSX.utils.aoa_to_sheet(aoa); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); /* export SheetJS workbook object to XLSX file bytes */ var data = XLSX.write(wb, {bookType: 'xlsx', type: 'array'}); /* build FormData with the generated file */ var fdata = new FormData(); fdata.append('file', new File([data], 'sheetjs.xlsx')); // field name ^^^^ file name ^^^^^^^^^^^^ /* send data using axios */ axios("https://s2c.sheetjs.com", { method: "POST", data: fdata }); ``` -------------------------------- ### Export spreadsheet data in HonoJS Source: https://docs.sheetjs.com/docs/demos/net/server/hono Full example of a GET route that generates an XLSX file from an array of arrays and returns it as a downloadable response. ```javascript import { Hono } from 'hono'; import { utils, write } from "xlsx"; const app = new Hono(); app.get("/export", (c) => { /* generate SheetJS workbook object */ var ws = utils.aoa_to_sheet(["SheetJS".split(""), [5,4,3,3,7,9,5]]); var wb = utils.book_new(ws, "Data"); /* generate buffer */ var buf = write(wb, {type: "buffer", bookType: "xlsx"}); /* set headers */ c.header('Content-Disposition', 'attachment; filename="SheetJSHonoJS.xlsx"'); c.header('Content-Type', 'application/vnd.ms-excel'); /* export buffer */ return c.body(buf); }); export default app; ``` -------------------------------- ### Start Server Source: https://docs.sheetjs.com/docs/demos/net/server/fastify Command to launch the Fastify server. ```bash node SheetJSFastify.js ``` -------------------------------- ### Build and Serve Site with npm and http-server Source: https://docs.sheetjs.com/docs/demos/static/vitejs Stop the dev server and use these commands to build the production site and serve it locally. ```bash npm run build npx -y http-server dist/ ``` -------------------------------- ### Create Kaioken Project with TF.js Source: https://docs.sheetjs.com/docs/demos/math/tensorflow Installs Kaioken and Vite plugin for a new TypeScript project. Use this to start a new project integrating SheetJS and TF.js. ```bash npm create vite sheetjs-tfjs-kaioken -- --template vanilla-ts --no-rolldown --no-interactive cd sheetjs-tfjs-kaioken npm add --save kaioken npm add --save vite-plugin-kaioken -D ``` -------------------------------- ### ViteJS Project Setup with SheetJS Source: https://docs.sheetjs.com/docs/demos/static/vitejs Commands to create a new ViteJS project with the Vue TypeScript template, install SheetJS from a CDN, and set up the project structure. ```bash npm create vite@5 sheetjs-vite -- --template vue-ts --no-rolldown --no-interactive cd sheetjs-vite npm i npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz ``` -------------------------------- ### Create New Bun Project Source: https://docs.sheetjs.com/docs/getting-started/installation/bun Initialize a new project directory and set up a new Bun project. ```bash mkdir sheetjs-bun-dle cd sheetjs-bun-dle bun init -y ``` -------------------------------- ### Create Project Folder and Initialize npm Source: https://docs.sheetjs.com/docs/demos/cloud/azure Use these commands to create a new directory for your project and initialize it with npm. ```bash mkdir SheetJSBlob cd SheetJSBlob npm init -y ``` -------------------------------- ### Verify Tauri Environment Setup Source: https://docs.sheetjs.com/docs/demos/desktop/tauri Run this command to check if all necessary dependencies for building Tauri apps are installed. Look for a checkmark next to 'Environment' to confirm. ```bash npx @tauri-apps/cli@1 info ``` -------------------------------- ### Scrape HTML Table to XLSX with JSDOM Source: https://docs.sheetjs.com/docs/demos/net/dom This example uses JSDOM to parse an HTML string, extract the first table, and convert it into an XLSX workbook. Ensure you have SheetJS and JSDOM installed. ```javascript const XLSX = require("xlsx"); const { readFileSync } = require("fs"); const { JSDOM } = require("jsdom"); /* obtain HTML string. This example reads from SheetJSTable.html */ const html_str = readFileSync("SheetJSTable.html", "utf8"); /* get first TABLE element */ const doc = new JSDOM(html_str).window.document.querySelector("table"); /* generate workbook */ const workbook = XLSX.utils.table_to_book(doc); XLSX.writeFile(workbook, "SheetJSDOM.xlsx"); ``` -------------------------------- ### Test Server with Sample File Source: https://docs.sheetjs.com/docs/demos/net/server Commands to download a sample file and test the conversion service via POST request. ```bash curl -LO https://docs.sheetjs.com/pres.numbers curl -X POST -F upload=@pres.numbers http://localhost:7262/ -J -O ``` -------------------------------- ### Install and Build with Webpack 5.x Source: https://docs.sheetjs.com/docs/demos/frontend/bundler/webpack Install Webpack 5.x and the CLI, then build your project for production. ```bash npm i --save webpack@5.x webpack-cli@5.x npx webpack --mode=production ``` -------------------------------- ### Preact Project Setup for SheetJS Source: https://docs.sheetjs.com/docs/demos/frontend/react Commands to create a new Preact project, install SheetJS, and run the development server. Requires updating imports and appending App component rendering. ```bash npm init preact sheetjs-preact cd sheetjs-preact npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz npm run dev ``` -------------------------------- ### Initialize iOS Capacitor Project Source: https://docs.sheetjs.com/docs/demos/mobile/capacitor Install the iOS platform and add it to the Capacitor project. ```bash npm i --save @capacitor/ios npx cap add ios ``` -------------------------------- ### Undefined XLSX Variable Error Examples Source: https://docs.sheetjs.com/docs/miscellany/errors These errors indicate that the XLSX variable is not defined, usually because the library was not loaded correctly. Review the installation instructions and ensure proper import methods are used. ```javascript Uncaught TypeError: Cannot read property 'read' of undefined ``` ```javascript Uncaught TypeError: Cannot read property 'writeFile' of undefined ``` ```javascript Uncaught TypeError: Cannot read property 'utils' of undefined ``` -------------------------------- ### Export to Numbers Format in NodeJS Source: https://docs.sheetjs.com/docs/api/write-options This NodeJS example shows how to export a spreadsheet to a .numbers file. It requires installing the package and importing the necessary modules, including xlsx.zahl. The 'numbers' option must be provided with the XLSX_ZAHL_PAYLOAD. ```javascript var XLSX = require("xlsx"); var XLSX_ZAHL_PAYLOAD = require("xlsx/dist/xlsx.zahl"); var wb = XLSX.utils.book_new(); var ws = XLSX.utils.aoa_to_sheet([ ["SheetJS", "<3","விரிதாள்"], [72,,"Arbeitsblätter"], [,62,"数据"], [true,false,], ]); XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); XLSX.writeFile(wb, "textport.numbers", {numbers: XLSX_ZAHL_PAYLOAD, compression: true}); ``` -------------------------------- ### Run the Server Source: https://docs.sheetjs.com/docs/demos/net/server/hono Start the HonoJS development server using Bun. The output will provide the local URL for accessing the server. ```bash bun run dev ``` -------------------------------- ### Fetch and Prepare Data File Source: https://docs.sheetjs.com/docs/demos/static/svelte Downloads the example spreadsheet file and places it in the data directory. ```bash mkdir -p data curl -Lo data/pres.xlsx https://docs.sheetjs.com/pres.xlsx ``` -------------------------------- ### Define Merge Range in Worksheet Source: https://docs.sheetjs.com/docs/csf/features/merges Use the `!merges` property of the worksheet object to define merged ranges. Each range object specifies the start and end cell of the merge. This example creates a merge for the range A1:B2. ```javascript ws["!merges"] = [ { s: { c: 0, r: 0 }, e: { c: 1, r: 1 } } // A1:B2 ]; ``` -------------------------------- ### Complete Example: Read, Process, and Write Spreadsheets Source: https://docs.sheetjs.com/docs/demos/math/pandas This script demonstrates the complete workflow of reading a spreadsheet file, generating a Pandas DataFrame from a specific worksheet, and then exporting that DataFrame to a new spreadsheet file. It requires the SheetJSWrapper to be installed and configured. ```python #!/usr/bin/env python3 from sheetjs import SheetJSWrapper with SheetJSWrapper() as sheetjs: # Parse file wb = sheetjs.read_file("pres.numbers") print("Loaded file pres.numbers") # Get first worksheet name first_ws_name = wb.get_sheet_names()[0] print(f"Reading from sheet {first_ws_name}") # Generate DataFrame from first worksheet df = wb.get_df(first_ws_name) print(df.info()) # Export DataFrame to XLSB sheetjs.write_df(df, "SheetJSPandas.xlsb", sheet_name="DataFrame") ``` -------------------------------- ### Prepare Project Structure Source: https://docs.sheetjs.com/docs/demos/net/server/nestjs Commands to create an upload directory and generate a controller. ```bash mkdir -p upload ``` ```bash npx @nestjs/cli generate controller sheetjs ``` -------------------------------- ### Serve Production Build Locally Source: https://docs.sheetjs.com/docs/demos/static/svelte Starts a local web server using http-server to host the production build of the static site. ```bash npx -y http-server build ``` -------------------------------- ### Install and Use NodeJS LTS with nvm Source: https://docs.sheetjs.com/docs/miscellany/contributing After installing nvm, install the latest Long Term Support (LTS) version of NodeJS and verify the installation. Requires a new terminal session after nvm installation. ```bash nvm install --lts node --version ``` -------------------------------- ### Check Swift Installation Source: https://docs.sheetjs.com/docs/demos/engines/jsc Verify if Swift is installed on your system. If not, install Xcode. ```bash swiftc --version ``` -------------------------------- ### Initialize Project Folder Source: https://docs.sheetjs.com/docs/demos/engines/jsc Create a dedicated directory for the WebKit build process. ```bash mkdir sheetjs-jsc cd sheetjs-jsc ``` -------------------------------- ### Add Start Property to President Object Source: https://docs.sheetjs.com/docs/getting-started/examples/export Assigns the start date of the first presidential term to the 'start' property of a president object. This is a helper function for adding the start date. ```javascript const prez_add_start = prez => prez.start = first_prez_term_start(prez); ``` -------------------------------- ### Build Sample Application Source: https://docs.sheetjs.com/docs/demos/engines/quickjs This snippet shows the command to compile the `sheetjs.quick.c` program with `gcc`, linking against `libquickjs.a` and the math library. ```bash gcc -o sheetjs.quick -Wall sheetjs.quick.c libquickjs.a -lm ``` -------------------------------- ### Install SheetJS and Puppeteer with bun Source: https://docs.sheetjs.com/docs/demos/net/headless Install SheetJS and Puppeteer using bun. This command installs the specified versions of both libraries. ```bash bun install https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz puppeteer@24.9.0 ``` -------------------------------- ### Install Wails CLI Source: https://docs.sheetjs.com/docs/demos/desktop/wails Installs the Wails command-line interface using Go. Ensure you have a recent version of Go installed. ```bash go install github.com/wailsapp/wails/v2/cmd/wails@latest ``` -------------------------------- ### Initialize Project Source: https://docs.sheetjs.com/docs/demos/cloud/airtable Commands to create a new directory and initialize a Node.js project. ```bash mkdir -p sheetjs-airtable cd sheetjs-airtable npm init -y ``` -------------------------------- ### Install Dependencies with Homebrew Source: https://docs.sheetjs.com/docs/demos/engines/chakra Installs ICU and CMake using Homebrew. Ensure CMake version 3 or higher is installed. ```bash brew install icu4c cmake ``` -------------------------------- ### Compile and run hello-world with g++ Source: https://docs.sheetjs.com/docs/demos/engines/v8 Standard build commands for Linux and macOS environments. ```bash g++ -I. -Iinclude samples/hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -lv8_libbase -lv8_libplatform -ldl -Lout.gn/x64.release.sample/obj/ -pthread \ -std=c++20 -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX ./hello_world ``` ```bash g++ -I. -Iinclude samples/hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -lv8_libbase -lv8_libplatform -ldl -Lout.gn/arm64.release.sample/obj/ -pthread \ -std=c++20 -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX ./hello_world ``` -------------------------------- ### Install SheetJS and pg-format Source: https://docs.sheetjs.com/docs/demos/data/postgresql Installs the SheetJS library and the pg-format package using npm. Ensure you have Node.js and npm installed. ```bash npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz pg-format@1.0.4 ``` -------------------------------- ### Build and run from project folder Source: https://docs.sheetjs.com/docs/demos/engines/v8 Commands to compile and execute the project after setting up local links. ```bash g++ -I. -Iinclude hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -lv8_libbase -lv8_libplatform -ldl -Lobj/ -pthread -std=c++20 \ -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX ./hello_world ``` ```bash g++ -I. -Iinclude hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -ldl -Lobj/ -pthread -std=c++20 \ -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX ./hello_world ``` ```bash g++ -I. -Iinclude hello-world.cc -o hello_world -fno-rtti -lv8_monolith \ -ldl -Lobj/ -pthread -std=c++20 \ -DV8_COMPRESS_POINTERS=1 -DV8_ENABLE_SANDBOX -framework Foundation ./hello_world ``` ```cmd cl /MT /I..\v8\v8\ /I..\v8\v8\include hello-world.cc /GR- v8_monolith.lib Advapi32.lib Winmm.lib Dbghelp.lib /std:c++20 /DV8_COMPRESS_POINTERS=1 /DV8_ENABLE_SANDBOX /link /out:hello_world.exe /LIBPATH:..\v8\v8\out.gn\x64.release.sample\obj\ .\hello_world.exe ``` -------------------------------- ### Check Git Version Source: https://docs.sheetjs.com/docs/miscellany/contributing Verifies that Git is installed and accessible in your terminal. If Xcode or command-line tools are not installed on macOS, this will prompt their installation. ```bash git --version ``` -------------------------------- ### Install Playwright Browsers Source: https://docs.sheetjs.com/docs/demos/net/headless Download and install browser engines for Playwright. This command is necessary if Playwright was just installed or updated, or if browsers are missing. ```bash npx playwright install ``` -------------------------------- ### Initialize depot_tools Source: https://docs.sheetjs.com/docs/demos/engines/v8 Runs the 'gclient' command to initialize depot_tools. This command fetches necessary dependencies and configures the environment. It's recommended to run this after setting up the PATH. ```bash gclient ``` -------------------------------- ### Install SheetJS and Playwright with BunJS Source: https://docs.sheetjs.com/docs/demos/net/headless Install SheetJS and Playwright using BunJS. This command installs the specified versions of SheetJS and Playwright. ```bash bun install https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz playwright@1.49.1 ```