0.4.1 • Published 8 months ago

basic-xlsx-reader v0.4.1

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

rust-wasm binding that uses calamine to read XLSX files

import init, {BasicXLSXReader} from 'basic-xlsx-reader';

const readFileAsUInt8Array = (file: File): Int8Array => {
    return new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = function () {
            const data = reader.result;
            const array = new Int8Array(data);
            resolve(array);
        };
        reader.onerror = reject;
        reader.readAsArrayBuffer(file);
    });
};

(async () => {
    await init();
    const input = document.querySelector('input[type=file]');
    const fileUint8Array = await readFileAsUInt8Array([input.files]);
    const basicXLSXReader = new BasicXLSXReader(fileUint8Array);
    const output = basicXLSXReader.read({
        headerRow: 1, // 0 indexed
        sheet: {name: "Test Sheet"}, // omit to get all sheets
        includeEmptyCells: true,
    });

    console.log(output);
})();

;

/*
{
  "sheets": [
    {
      "sheet": "Test Sheet",
      "row": [
        {
          "columns": [
            {
                "header": "Column 1",
                "value": "Test Cell"
            },
            {
                "header": "Column 2",
                "value": 2
            }
          ]
        }
      ]
    }
  ]
}

 */
0.4.1

8 months ago

0.4.0

9 months ago

0.3.0

9 months ago

0.2.6

9 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.0

9 months ago