欢迎回来

登录 EAKE AI,继续您的智能之旅

忘记密码?
还没有账号?立即注册

Excel表格处理 — .xlsx/csv读写编辑图表

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 ![Build Status](https://github.com/SheetJS/sheetjs/actions) ![Snyk Vulnerabilities](https://snyk.io/test/github/SheetJS/sheetjs) ![npm Downloads](https://npmjs.org/package/xlsx) ![Analytics](https://github.com/SheetJS/sheetjs)

Browser Test and Support Matrix

![Build Status](https://saucelabs.com/u/sheetjs)

Supported File Formats

![circo graph of format support](formats.png)

![graph legend](legend.png)

Table of Contents

<details> <summary><b>Expand to show Table of Contents</b></summary>

<!-- toc -->

  • [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)

<!-- 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

来源

安装指南

复制下方命令,在终端运行即可安装:

npx skills add xlsx
npx skills add xlsx -g
⚡ 一键安装到 GenHub

需已安装 GenHub 桌面端

使用指南

安装完成后,在对话框中直接使用此技能。

基本信息
作者 sheetjs 分类 efficiency 难度 Beginner 时长 1 hour
🛠️ 安装命令
npx skills add xlsx
npx skills add xlsx -g

发表评论