Excel表格处理 — .xlsx/csv读写编辑图表
处理电子表格文件的完整工具箱:读写编辑.xlsx/.xlsm/.csv/.tsv,添加列、计算公式、格式化、图表制作、数据清洗,从零创建或从其他数据源导入。
SheetJS
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 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    
Browser Test and Support Matrix

Supported File Formats


Table of Contents
<details> <summary><b>Expand to show Table of Contents</b></summary>
<!-- toc -->
- [Getting Started](#getting-started)
- [Acquiring and Extracting Data](#acquiring-and-extracting-data)
- [Processing Data](#processing-data)
- [Packaging and Releasing Data](#packaging-and-releasing-data)
- [Interface](#interface)
- [Common Spreadsheet Format](#common-spreadsheet-format)
- [Parsing Options](#parsing-options)
- [Writing Options](#writing-options)
- [Utility Functions](#utility-functions)
- [File Formats](#file-formats)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [References](#references)
* [Installation](#installation) * [Usage](#usage) * [The Zen of SheetJS](#the-zen-of-sheetjs) * [JS Ecosystem Demos](#js-ecosystem-demos)
* [Parsing Workbooks](#parsing-workbooks) * [Processing JSON and JS Data](#processing-json-and-js-data) * [Processing HTML Tables](#processing-html-tables)
* [Modifying Workbook Structure](#modifying-workbook-structure) * [Modifying Cell Values](#modifying-cell-values) * [Modifying Other Worksheet / Workbook / Cell Properties](#modifying-other-worksheet--workbook--cell-properties)
* [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)
* [Parsing functions](#parsing-functions) * [Writing functions](#writing-functions) * [Utilities](#utilities)
* [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)
* [Input Type](#input-type) * [Guessing File Type](#guessing-file-type)
* [Supported Output Formats](#supported-output-formats) * [Output Type](#output-type)
* [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)
* [Node](#node) * [Browser](#browser) * [Tested Environments](#tested-environments) * [Test Files](#test-files)
* [OSX/Linux](#osxlinux) * [Windows](#windows) * [Tests](#tests)
<!-- tocstop -->
</details>
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:
<script lang="javascript" src="dist/xlsx.full.min.js"></script>
<details> <summary><b>CDN Availability</b> (click to show)</summary>
| CDN | URL |
|-----------:|:-------------------------------------------|
| unpkg | <https://unpkg.com/xlsx/> |
| jsDelivr | <https://jsdelivr.com/package/npm/xlsx> |
| CDNjs | <https://cdnjs.com/libraries/xlsx> |
For example, unpkg makes the latest version available at:
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
</details>
<details> <summary><b>Browser builds</b> (click to show)</summary>
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
</details>
With bower:
$ 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:
<script type="module">
import { read, writeFileXLSX } from "./xlsx.mjs";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "./xlsx.mjs";
import * as cptable from './dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>
The npm package also exposes the module with the module parameter, supported in Angular and other projects:
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:
// @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:
$ npm install xlsx
By default, the module supports require:
var XLSX = require("xlsx");
The module also ships with xlsx.mjs for use with import:
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/cpexcel.full.mjs';
XLSX.set_cptable(cpexcel);
Photoshop and InDesign
dist/xlsx.extendscript.js is an ExtendScript build for Photoshop and InDesign that is included in the npm package. It can be directly referenced with a #include directive:
#include "xlsx.extendscript.js"
<details> <summary><b>Internet Explorer and ECMAScript 3 Compatibility</b> (click to show)</summary>
For broad compatibility with JavaScript engines, the library is written using
(内容节选自官方 README)
安装
# 安装到当前项目
npx skills add xlsx
# 全局安装
npx skills add xlsx -g
来源
- 作者:
sheetjs - 仓库:://github.com/SheetJS/sheetjs
- npm 包:
xlsx
使用指南
安装完成后,在对话框中直接使用此技能。