[英]How to read only column A value from excel using nodejs?
How to read only Column A value from excel using nodejs(node-xlsx) ?如何使用 nodejs(node-xlsx) 从 excel 中仅读取 A 列值? Please advise.
请指教。 After reading all the column values then loop through to search from other source.
读取所有列值后,然后循环从其他来源进行搜索。
var xlsx = require('node-xlsx');
var obj = xlsx.parse(__dirname + '/test.xlsx');
var obj = xlsx.parse(fs.readFileSync(__dirname + '/test.xlsx'));
console.log(JSON.stringify(obj));
Try other npm package called: xlsx
:尝试其他名为:
xlsx
npm 包:
'use strict';
const _ = require('lodash');
const xlsx = require('xlsx');
const workbook = xlsx.readFile('./data/pv.xlsx');
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const columnA = [];
for (let z in worksheet) {
if(z.toString()[0] === 'A'){
columnA.push(worksheet[z].v);
}
}
console.log(columnA);
const XLSX = require("xlsx");
const workbook = XLSX.readFile("DummyExcel.xlxs"); //read the file
const worksheet = workbook.Sheets["Execution Summary"]; //get the worksheet by name. you can put sheet id also
//print the value of desired cell or range of cell
console.log(
"worksheet:",
XLSX.utils.sheet_to_json(worksheet, {
raw: true,
range: "B5:B10",
defval: null,
})
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.