How does the code should look like to get cell A1 value from the file "C:\1.xlsx"? I tried numbers of examples but still didn't managed to get it work.
var Excel = require('exceljs');
var workbook = new Excel.Workbook();
workbook.xlsx.readFile("C:\1.xlsx")
.then(function() {
var worksheet = workbook.getWorksheet('Sheet1');
var cell = worksheet.getCell('A1').value;
console.log(cell);
});
I see no errors, but it doesn't work.
Method #1: OpenPyXL OpenPyXL is a Python library created for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files. It can read both the . xlsx and . xlsm file formats, which includes support for charts, graphs, and other data visualizations.
If your computer does not have Excel for Windows® or if you are using MATLAB® Online™, xlsread automatically operates in basic import mode, which supports XLS, XLSX, XLSM, XLTX, and XLTM files.
You have to access the worksheet first and then the cell. Like this:
var Excel = require('exceljs');
var workbook = new Excel.Workbook();
workbook.xlsx.readFile("C:/1.xlsx")
.then(function() {
ws = workbook.getWorksheet("Sheet1")
cell = ws.getCell('A1').value
console.log(cell)
});
Replace "Sheet1" with the real sheet's name. You can also access the worksheet by id.
ws = workbook.getWorksheet(1)
I guess you need to use getCell().value
, like:
var cell = worksheet.getCell('C3').value;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With