I have an excel sheet there are two columns one is the product name and the other is the product price and the price column is empty, to get the price I have to call API and then update the excel sheet with that price How can I achieve this?
You can use exceljs to work with excels. You can do something like this:
const Excel = require('exceljs');
const workbook = new Excel.Workbook();
workbook.xlsx.readFile('path to file')
.then(() => {
const worksheet = workbook.getWorksheet(1);
const row = worksheet.getRow(15);
row.getCell(1).value = 'pass_new_value';
row.commit();
return workbook.xlsx.writeFile('path-to-new-file');
}).catch((e) => {
console.log(e);
})
I would suggest you get all the data first and then write to the sheet instead of updating one column at a time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.