Import and export from XLSX files

This examples shows the JSS Parser and JSS Render premium extensions and required specific licenses.

The extensions helps to convert a XLSX file into JSS and export a JSS spreadsheet to a XLSX file. Both extensions require a specific license.





The best results would be in combination with Jspreadsheet Version 8 with Formula Pro



Source code

Using CDN
Using NPM
<html>
<script src="https://jspreadsheet.com/v7/jspreadsheet.js"></script>
<script src="https://jsuites.net/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v4/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v7/jspreadsheet.css" type="text/css" />

<script src="https://cdn.jsdelivr.net/npm/jszip@3.6.0/dist/jszip.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/parser@1.1.1/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/render@1.2.0/dist/index.min.js"></script>

<div id="spreadsheet"></div>

<script>
// Set your license
jspreadsheet.license = 'your-license-here';

//Set extensions
jspreadsheet.setExtensions({ parser, render });

// Create the spreadsheet from a local file
var load = function(e) {
    // Destroy any existing JSS
    jspreadsheet.destroy(document.getElementById('spreadsheet'));

    // Parse XLSX file and create a new spreadsheet
    jspreadsheet.parser({
        file: e.target.files[0],
        onload: function(config) {
            jspreadsheet(document.getElementById('spreadsheet'), config.worksheets);
        },
    });
}

var download = function() {
    // Render receives the DOM Element
    jspreadsheet.render(document.getElementById('spreadsheet'));
}
</script>
</html>
import React, { useRef, useEffect } from "react";
import jspreadsheet from "jspreadsheet-pro";
import parser from "@jspreadsheet/parser";
import "jspreadsheet-pro/dist/jspreadsheet.css";
import "jsuites/dist/jsuites.css";

export default function App() {
  const spreadsheetRef = useRef(null);
  const license = "OWU5NmEwNjY1ODQxNDg4ODYyMjRlYjU0YzBmMmI1MDAxNTI1NzJlZWQyN2RmN2RiZjE0NGRhY2M0NzIyNjlhYWI2YTBlNGFkMzhjM2E0ZDZkZDZlYjhkNjkyMTNjZWM5ODYzMDE1ZWEzYjlmM2M0N2NmNDNiYzcwM2MzNjNhNzcsZXlKdVlXMWxJam9pY0dGMWJDNW9iMlJsYkNJc0ltUmhkR1VpT2pFMk5ETTJOek0yTURBc0ltUnZiV0ZwYmlJNld5SmpjMkl1WVhCd0lpd2lhbk5tYVdSa2JHVXVibVYwSWl3aWQyVmlMbUZ3Y0NJc0lteHZZMkZzYUc5emRDSmRMQ0p3YkdGdUlqb2lNeUo5";

  jspreadsheet.license = license;
  jspreadsheet.setExtensions({ parser });

  //Create the spreadsheet from a local file
  let load = function (e) {
    // Destroy any existing JSS
    jspreadsheet.destroy(spreadsheetRef.current);

    // Parse XLSX file and create a new spreadsheet
    jspreadsheet.parser({
      file: e.target.files[0],
      onload: function (config) {
        jspreadsheet(spreadsheetRef.current, config.worksheets);
      }
    });
  };

  return (
    <div>
      <div ref={spreadsheetRef} />
      <input type="file" name="file" id="file" onChange={(e) => load(e)} />
    </div>
  );
}


Working example using NPM

https://codesandbox.io/s/jss-spreadsheet-to-xlsx-z0sol