https://github.com/borgar/xlsx-convert
Utility to convert Excel XLSX files to JSON
https://github.com/borgar/xlsx-convert
excel json spreadsheet workbook xlsx
Last synced: 3 months ago
JSON representation
Utility to convert Excel XLSX files to JSON
- Host: GitHub
- URL: https://github.com/borgar/xlsx-convert
- Owner: borgar
- License: mit
- Created: 2021-02-15T19:58:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-08T13:01:40.000Z (over 1 year ago)
- Last Synced: 2025-01-16T17:19:44.270Z (over 1 year ago)
- Topics: excel, json, spreadsheet, workbook, xlsx
- Language: JavaScript
- Homepage:
- Size: 322 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XLSX-convert
This is a utility to convert Excel XLSX files to JSON format. It supports only XLSX files and outputs JSF, [JSON spreadsheet format](https://github.com/jsfkit/types) ([see below](#output)).
The library will run in a browser as well as in server environments (Node, Deno, Bun, etc.).
This utility was developed as tooling for [GRID – The new face of spreadsheets](https://grid.is/), to which it owes a debt of gratitude.
## Installing
The library is also provided as an NPM package:
$ npm install @borgar/xlsx-convert
## Usage
```js
// import the converter
import xlsxConvert from '@borgar/xlsx-convert';
// read the file
const jsf = await xlsxConvert('path/to/workbook.xlsx', options);
// emit results
console.log(jsf);
```
This will emit a structure like this:
```js
{
"filename": "workbook.xlsx",
"sheets": [
{
"cells": {
"A1": { "v": 12 },
"B1": { "v": 123.1 },
"A2": { "v": "Total" },
"B2": { "v": 135.1, "f": "SUM(A1:B1)", },
},
"merges": [],
"colWidths": [],
"rowHeights": [],
"hidden": 0,
"name": "Sheet1"
}
],
"names": [],
"styles": [
{ "font-size": 12 }
]
}
```
### # Output:
The [JSON spreadsheet format](https://jsfkit.github.io/types/) is similar to, but not compatible with the [CSF structure](https://github.com/SheetJS/sheetjs#common-spreadsheet-format) used by the [`xlsx` package](https://github.com/SheetJS/sheetjs).
Supported cell properties are:
| Cell. | Note |
|- |-
| `v` | Value of the cell in its correct type.
| `f` | An integer index into a list of formula expressions in R1C1-syntax, or an expression string in A1-syntax.
| `F` | The A1-style range of enclosing array if the formula is an array formula.
| `c` | A list of comments attached to the cell.
| `s` (optional) | Index of style information associated with the cell.
| `t` (optional) | A type for the value in the cell (this library only emits an `"e"` when the value is an error).
| `l` (optional) | A URL attached to the cell.
Only cells that have "relevant data" are emitted, which in praxis means cells that have such things as values, formula, and visible styles attached to them.
## Documentation
Documentation can be found under [docs/](./docs/):
* The API is documented in [docs/API.md](./docs/API.md).
* The JSF output is documented at [jsfkit.github.io](https://jsfkit.github.io/types/).