Home  >  Article  >  Web Front-end  >  A brief discussion on how nodejs uses the node-xlsx module to read excel data

A brief discussion on how nodejs uses the node-xlsx module to read excel data

青灯夜游
青灯夜游forward
2021-04-07 10:00:424834browse

This article will introduce to you nodejsHow to use the node-xlsx module to read excel table data. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

A brief discussion on how nodejs uses the node-xlsx module to read excel data

Related recommendations: "nodejs Tutorial"

1. Install node-xlsx

node-xlsx module is used to read the content in the xlsx file, which is the content of the excel table

npm install node-xlsx --save

2. Use node-xlsx Reading table data

const nodeXlsx = require('node-xlsx')	//引用node-xlsx模块

//下方ex1是读取出来的数组,数组长度取决于Excel文件的工作表(sheet)
const ex1 = nodeXlsx.parse("./ex1.xls")	//读取excel表格

let excel_content = ex1[0].data	//取出excel文件中的第一个工作表中的全部数据

excel_content .splice(0,1)	//一般来说表中的第一条数据可能是标题没有用,所以删掉

console.log(excel_content)	//查看读取出来的数据

For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of A brief discussion on how nodejs uses the node-xlsx module to read excel data. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete