如何使用 nodejs 只读取 excel 中的 A 列值?

How to read only column A value from excel using nodejs?

如何使用 nodejs(node-xlsx) 只读取 excel 中的 A 列值?请指教。读取所有列值后循环搜索其他来源。

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));

尝试其他名为: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,
  })
);