excel、json互转
立即下载
资源介绍:
excel、json互转
# [SheetJS](https://sheetjs.com)
The SheetJS Community Edition offers battle-tested open-source solutions for
extracting useful data from almost any complex spreadsheet and generating new
spreadsheets that will work with legacy and modern software alike.
[SheetJS Pro](https://sheetjs.com/pro) offers solutions beyond data processing:
Edit complex templates with ease; let out your inner Picasso with styling; make
custom sheets with images/graphs/PivotTables; evaluate formula expressions and
port calculations to web apps; automate common spreadsheet tasks, and much more!
![License](https://img.shields.io/github/license/SheetJS/sheetjs)
[![Build Status](https://img.shields.io/github/workflow/status/sheetjs/sheetjs/Tests:%20node.js)](https://github.com/SheetJS/sheetjs/actions)
[![Snyk Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/SheetJS/sheetjs)](https://snyk.io/test/github/SheetJS/sheetjs)
[![npm Downloads](https://img.shields.io/npm/dm/xlsx.svg)](https://npmjs.org/package/xlsx)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/sheetjs?pixel)](https://github.com/SheetJS/sheetjs)
[**Browser Test and Support Matrix**](https://oss.sheetjs.com/sheetjs/tests/)
[![Build Status](https://saucelabs.com/browser-matrix/sheetjs.svg)](https://saucelabs.com/u/sheetjs)
**Supported File Formats**
![circo graph of format support](formats.png)
![graph legend](legend.png)
## Table of Contents
Expand to show Table of Contents
- [Getting Started](#getting-started)
* [Installation](#installation)
* [Usage](#usage)
* [The Zen of SheetJS](#the-zen-of-sheetjs)
* [JS Ecosystem Demos](#js-ecosystem-demos)
- [Acquiring and Extracting Data](#acquiring-and-extracting-data)
* [Parsing Workbooks](#parsing-workbooks)
* [Processing JSON and JS Data](#processing-json-and-js-data)
* [Processing HTML Tables](#processing-html-tables)
- [Processing Data](#processing-data)
* [Modifying Workbook Structure](#modifying-workbook-structure)
* [Modifying Cell Values](#modifying-cell-values)
* [Modifying Other Worksheet / Workbook / Cell Properties](#modifying-other-worksheet--workbook--cell-properties)
- [Packaging and Releasing Data](#packaging-and-releasing-data)
* [Writing Workbooks](#writing-workbooks)
* [Writing Examples](#writing-examples)
* [Streaming Write](#streaming-write)
* [Generating JSON and JS Data](#generating-json-and-js-data)
* [Generating HTML Tables](#generating-html-tables)
* [Generating Single-Worksheet Snapshots](#generating-single-worksheet-snapshots)
- [Interface](#interface)
* [Parsing functions](#parsing-functions)
* [Writing functions](#writing-functions)
* [Utilities](#utilities)
- [Common Spreadsheet Format](#common-spreadsheet-format)
* [General Structures](#general-structures)
* [Cell Object](#cell-object)
+ [Data Types](#data-types)
+ [Dates](#dates)
* [Sheet Objects](#sheet-objects)
+ [Worksheet Object](#worksheet-object)
+ [Chartsheet Object](#chartsheet-object)
+ [Macrosheet Object](#macrosheet-object)
+ [Dialogsheet Object](#dialogsheet-object)
* [Workbook Object](#workbook-object)
+ [Workbook File Properties](#workbook-file-properties)
* [Workbook-Level Attributes](#workbook-level-attributes)
+ [Defined Names](#defined-names)
+ [Workbook Views](#workbook-views)
+ [Miscellaneous Workbook Properties](#miscellaneous-workbook-properties)
* [Document Features](#document-features)
+ [Formulae](#formulae)
+ [Row and Column Properties](#row-and-column-properties)
+ [Number Formats](#number-formats)
+ [Hyperlinks](#hyperlinks)
+ [Cell Comments](#cell-comments)
+ [Sheet Visibility](#sheet-visibility)
+ [VBA and Macros](#vba-and-macros)
- [Parsing Options](#parsing-options)
* [Input Type](#input-type)
* [Guessing File Type](#guessing-file-type)
- [Writing Options](#writing-options)
* [Supported Output Formats](#supported-output-formats)
* [Output Type](#output-type)
- [Utility Functions](#utility-functions)
* [Array of Arrays Input](#array-of-arrays-input)
* [Array of Objects Input](#array-of-objects-input)
* [HTML Table Input](#html-table-input)
* [Formulae Output](#formulae-output)
* [Delimiter-Separated Output](#delimiter-separated-output)
+ [UTF-16 Unicode Text](#utf-16-unicode-text)
* [HTML Output](#html-output)
* [JSON](#json)
- [File Formats](#file-formats)
- [Testing](#testing)
* [Node](#node)
* [Browser](#browser)
* [Tested Environments](#tested-environments)
* [Test Files](#test-files)
- [Contributing](#contributing)
* [OSX/Linux](#osxlinux)
* [Windows](#windows)
* [Tests](#tests)
- [License](#license)
- [References](#references)
## Getting Started
### Installation
**Standalone Browser Scripts**
The complete browser standalone build is saved to `dist/xlsx.full.min.js` and
can be directly added to a page with a `script` tag:
```html
```
CDN Availability (click to show)
| CDN | URL |
|-----------:|:-------------------------------------------|
| `unpkg` | |
| `jsDelivr` | |
| `CDNjs` | |
For example, `unpkg` makes the latest version available at:
```html
```
Browser builds (click to show)
The complete single-file version is generated at `dist/xlsx.full.min.js`
`dist/xlsx.core.min.js` omits codepage library (no support for XLS encodings)
A slimmer build is generated at `dist/xlsx.mini.min.js`. Compared to full build:
- codepage library skipped (no support for XLS encodings)
- no support for XLSB / XLS / Lotus 1-2-3 / SpreadsheetML 2003 / Numbers
- node stream utils removed
With [bower](https://bower.io/search/?q=js-xlsx):
```bash
$ bower install js-xlsx
```
**ECMAScript Modules**
The ECMAScript Module build is saved to `xlsx.mjs` and can be directly added to
a page with a `script` tag using `type=module`:
```html
```
The [npm package](https://www.npmjs.org/package/xlsx) also exposes the module
with the `module` parameter, supported in Angular and other projects:
```ts
import { read, writeFileXLSX } from "xlsx";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);
```
**Deno**
`xlsx.mjs` can be imported in Deno. It is available from `unpkg`:
```ts
// @deno-types="https://unpkg.com/xlsx/types/index.d.ts"
import * as XLSX from 'https://unpkg.com/xlsx/xlsx.mjs';
/* load the codepage support library for extended support with older formats */
import * as cptable from 'https://unpkg.com/xlsx/dist/cpexcel.full.mjs';
XLSX.set_cptable(cptable);
```
**NodeJS**
With [npm](https://www.npmjs.org/package/xlsx):
```bash
$ npm install xlsx
```
By default, the module supports `require`:
```js
var XLSX = require("xlsx");
```
The module also ships with `xlsx.mjs` for use with `import`:
```js
import * as XLSX from 'xlsx/xlsx.mjs';
/* load 'fs' for readFile and writeFile support */
import * as fs from 'fs';
XLSX.set_fs(fs);
/* load 'stream' for stream support */
import { Readable } from 'stream';
XLSX.stream.set_readable(Readable);
/* load the codepage support library for extended support with older formats */
import * as cpexcel from 'xlsx/dist