最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - get computed value of excel sheet cell in Node.js - Stack Overflow

programmeradmin0浏览0评论

I'm using node.js to process my excel sheets with exceljs module.

I'm writing values into few cells and other cells are already containing formulas. I want to trigger those formulas and want to store values in sheet programatically.

For E.g. I have below sheet structure:

I'hv written below code to insert values in cells A1 and B1.

var workbook = new Excel.Workbook();
workbook.xlsx.readFile(__base + 'test.xlsx')
  .then(function() {
    var worksheet = workbook.getWorksheet(2);
    var row = worksheet.getRow(1);
    row.getCell(1).value = 2; // A1's value set to 2
    row.getCell(2).value = 8; // B1's value set to 8
  };
  rowmit();
  workbook.xlsx.writeFile(__base + 'test.xlsx');                            
});

When I'm trying to fetch value of c1 then its returning me formula with result 0. Below is the code to fetch values.

workbook.xlsx.readFile(__base + 'test.xlsx')
    .then(function() {
    var worksheet = workbook.getWorksheet(2);
    var row = worksheet.getRow(1);
    console.log(row.getCell(1).value);
    console.log(row.getCell(2).value);
    console.log(row.getCell(3).value);
});

OUTPUT:

How to get puted values or how to trigger putation in excel programatically and to store it in cell?

Output result of cell C1 should be 10 in console i.e. A1+B1 (2+8).

I'm using node.js to process my excel sheets with exceljs module.

I'm writing values into few cells and other cells are already containing formulas. I want to trigger those formulas and want to store values in sheet programatically.

For E.g. I have below sheet structure:

I'hv written below code to insert values in cells A1 and B1.

var workbook = new Excel.Workbook();
workbook.xlsx.readFile(__base + 'test.xlsx')
  .then(function() {
    var worksheet = workbook.getWorksheet(2);
    var row = worksheet.getRow(1);
    row.getCell(1).value = 2; // A1's value set to 2
    row.getCell(2).value = 8; // B1's value set to 8
  };
  row.mit();
  workbook.xlsx.writeFile(__base + 'test.xlsx');                            
});

When I'm trying to fetch value of c1 then its returning me formula with result 0. Below is the code to fetch values.

workbook.xlsx.readFile(__base + 'test.xlsx')
    .then(function() {
    var worksheet = workbook.getWorksheet(2);
    var row = worksheet.getRow(1);
    console.log(row.getCell(1).value);
    console.log(row.getCell(2).value);
    console.log(row.getCell(3).value);
});

OUTPUT:

How to get puted values or how to trigger putation in excel programatically and to store it in cell?

Output result of cell C1 should be 10 in console i.e. A1+B1 (2+8).

Share Improve this question asked May 26, 2017 at 10:38 RupaliRupali 1,0781 gold badge13 silver badges20 bronze badges 1
  • Hi s-rupali, i have struggle this question about excel file download can you check my question: stackoverflow./questions/44451884/… – Vinoth Commented Jun 9, 2017 at 14:17
Add a ment  | 

2 Answers 2

Reset to default 4

hot-formula-parser can parse formulas... use in bination with exceljs

Here is the possible connecting code.

exceljs allows you to modify the file directly without using Excel.
There won't be any calcultation done at the file level, the result value will be the latest calculted by Excel last time you opened it.

If you open Excel, it will calculte everything and value will be correct.

发布评论

评论列表(0)

  1. 暂无评论