查询Excel表格中的某一列数据【Node.js实现】

版权声明:本文为博主原创文章,转载请注明出处,谢谢。 https://blog.csdn.net/qq846294282/article/details/82022316
const fs = require('fs')
const xlsx = require('node-xlsx')
 
const sheets = xlsx.parse('example.xlsx')
sheets.forEach(sheet => {
    // 获取整个excel中的数据
    const data = sheet['data']
	
    // 将需要的列数据组装成数组
    let array = []
    for(let rowId in data){
        const row = data[rowId]
        array.push(row[2])
    }

    // 可以进行各种数据处理,比如计量单位转换
    array.forEach((item, index) => {
        // here to insert your code 
    })

    console.log(array);
    console.log(array.length)
});

猜你喜欢

转载自blog.csdn.net/qq846294282/article/details/82022316
今日推荐