@aarongray.org/xlsx-workbook 中文文档教程

发布于 5年前 浏览 18 更新于 3年前

xlsx-workbook class

基于 https://github.com/SheetJS/sheetjs

install

npm install --save xlsx-workbook

Usage

const XLSXWorkbook = require("xlsx-workbook");

var wb = new XLSXWorkbook();

var spreadsheets = wb.getSpreadsheets

API

class XLSXWorkbook

    constructor(Buffer|URL|String) throws "XlsxWorkbook.constructor: bad input type";

    loadWorkbookFromBuffer(Buffer)

    loadWorkbookFromURL(URL)

    loadWorkbookFromFile(String)

    getSpreadsheetNames():String[]

    getSpreadsheetAsObject(name:String)
    getWorkbookAsObject():Object

    getWorkbook()

    saveWorkbookToFile(filename:String|Buffer|URL|Integer)

Example

test.js

test.js 的包装器一个基于需要的例子。

const XLSXWorkbook = require("./index.js");

const dataURL = new URL("https://fingertips.phe.org.uk/documents/Historic%20COVID-19%20Dashboard%20Data.xlsx");

var workbook = new XLSXWorkbook(dataURL);

var data = workbook.getWorkbookAsObject();

console.log(JSON.stringify(data, 2, 2));

workbook.saveWorkbookToFile(filename);

xlsx-workbook class

A wrapper based on https://github.com/SheetJS/sheetjs

install

npm install --save xlsx-workbook

Usage

const XLSXWorkbook = require("xlsx-workbook");

var wb = new XLSXWorkbook();

var spreadsheets = wb.getSpreadsheets

API

class XLSXWorkbook

    constructor(Buffer|URL|String) throws "XlsxWorkbook.constructor: bad input type";

    loadWorkbookFromBuffer(Buffer)

    loadWorkbookFromURL(URL)

    loadWorkbookFromFile(String)

    getSpreadsheetNames():String[]

    getSpreadsheetAsObject(name:String)
    getWorkbookAsObject():Object

    getWorkbook()

    saveWorkbookToFile(filename:String|Buffer|URL|Integer)

Example

test.js

test.js An example based on need.

const XLSXWorkbook = require("./index.js");

const dataURL = new URL("https://fingertips.phe.org.uk/documents/Historic%20COVID-19%20Dashboard%20Data.xlsx");

var workbook = new XLSXWorkbook(dataURL);

var data = workbook.getWorkbookAsObject();

console.log(JSON.stringify(data, 2, 2));

workbook.saveWorkbookToFile(filename);
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文