@aarongray.org/xlsx-workbook 中文文档教程
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);