node.jssheetjs

How to extract a cell value from a given .xlsx sheet in a workbook using "xlsx" package from node?


I want to extract a cell value from a given .xlsx file from a particular row and column in a given sheet from a workbook using a npm module ".xlsx". Please suggest me any way to extract the value so that I can use the test data from the sheet.

Given I was able to go to a particular sheet

const xlsx =require("xlsx"); 
const wb=xlsx.readFile("test_data.xlsx"); 
const ws=wb.Sheets["Sheet1"] 

Solution

  • Try to use this. You can install const xlsx-populate

    Then this the function

     XlsxPopulate.fromFileAsync("./Book1.xlsx")
            .then(workbook => {
    
                // choose the sheet and a cell.
                const value = workbook.sheet("Sheet1").cell("A1").value();
    
                console.log(value);
            });