Get started with xlsx CDN

Apache License, Version 2.0 licensed

Popular library for reading, writing Excel files in browsers.

Tags:
  • excel
  • spreadsheet
  • xlsx
  • xlsm
  • xlsb
  • parser

Stable version

Copied!

How to start using xlsx CDN


// Include the xlsx library using the CDN link
const XLSX = require('shim/xlsx');

// Read the Excel file as ArrayBuffer
fetch('path/to/your/file.xlsx')
  .then((response) => response.arrayBuffer())
  .then((arrayBuffer) => {
    // Create workbook from ArrayBuffer
    const workbook = XLSX.read(new Uint8Array(arrayBuffer), { cellStyles: true });

    // Select the first worksheet
    const worksheetName = workbook.SheetNames[0];
    const worksheet = workbook.Sheets[worksheetName];

    // Get data as JSON object
    const data = XLSX.utils.sheet_to_json(worksheet, { header: 1 });

    // Log the data
    console.log(data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions