Skip to content
jsf2xlsx

jsf2xlsx

jsf2xlsx is a TypeScript package to convert a JSF spreadsheet to an Excel workbook (.xlsx file).

To use jsf2xlsx as a project dependency, run:

Terminal window
npm install @grid-is/jsf2xlsx

Save this as xlsx.js and run it with node xlsx.js for a quick example of how to emit a .xlsx file using the library.

import { writeFileSync } from "node:fs";
import { toXlsx } from "@grid-is/jsf2xlsx";
// Create the simplest workbook.
const jsf = {
name: "demo.xlsx",
sheets: [
{
name: "Sheet1",
cells: {
A1: { v: 100 },
},
},
],
};
// Convert the JSF to an XLSX archive.
const zip = await toXlsx(jsf);
// Save the XLSX to a local file.
writeFileSync(jsf.name, new Uint8Array(zip.toArrayBuffer()));

The package includes a tool to convert JSF files into XLSX from the command line:

Terminal window
$ npx jsf2xlsx -h
Usage: jsf2xlsx <input> [-o <output>]
Converts JSF JSON to .xlsx via toXlsx.
Options:
-o, --output <file> Write XLSX output to a file (defaults to input name with .xlsx)
-h, --help Show this help text

The public interface to jsf2xlsx is the toXlsx function which relies heavily on the JSF Workbook type. Read all about them!