xlsx.utils.cells_to_sheet

Converts an array of arrays of cell objects to a worksheet.

Usage no npm install needed!

<script type="module">
  import xlsxUtilsCellsToSheet from 'https://cdn.skypack.dev/xlsx.utils.cells_to_sheet';
</script>

README

XLSX.utils.cells_to_sheet

XLSX.utils.cells_to_sheet(data)

Converts an array of arrays of cell objects to a worksheet.

setup

npm

npm i xlsx.utils.cells_to_sheet

ES module

import 'xlsx.utils.cells_to_sheet';
import XLSX from 'xlsx';

Node

require('xlsx.utils.cells_to_sheet');
let XLSX = require('xlsx');

browser

<script src="https://unpkg.com/xlsx"></script>
<script src="https://unpkg.com/xlsx.utils.cells_to_sheet"></script>

usage

let items = [
  {key: 'a', value: 0.543},
  {key: 'b', value: 0.164},
  {key: 'c', value: 0.774},
];
let ws = XLSX.utils.cells_to_sheet(items.map(item => [
  {t: 's', v: item.key},
  {t: 'n', v: item.value, z: '0%'},
]));