Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 views
in Technique[技术] by (71.8m points)

node.js - How to get names of workbook sheet without parsing the whole file in Node JS

I need the names of the workbook sheet without parsing the whole excel. My file contains 1 Million records so parsing the same each time take up lot of time. I am using the following code for now.

var xlsx = require('node-xlsx');
var obj = xlsx.parse('file location '+Filename);
console.log(JSON.stringify(obj))

This code first parses the whole file then provides the sheet name.

question from:https://stackoverflow.com/questions/65661441/how-to-get-names-of-workbook-sheet-without-parsing-the-whole-file-in-node-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Following code is working fine.

  const xPopWrapper = require("xlsx-populate-wrapper")
    const path = require("path")
    const filePath = path.resolve(filePathWithName)
    const workbook = new xPopWrapper(filePath)
    workbook.init().then(wb => {
    console.log(wb.getSheetNames())

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...