question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello!

After running the code below and when I open the file the cell shows =A1+B1. It seems that excel doesn’t understand that it is a formula in B1. What do I do wrong?

var Excel = require('exceljs');

exports.test = function(req, res){
  var workbook = new Excel.Workbook();
  var worksheet = workbook.addWorksheet("Sammanstallning");
  workbook.getWorksheet("Sammanstallning");
  worksheet.getCell("B1").value = '=A1+C1';
  worksheet.getCell("C1").value = 0.14;

  workbook.xlsx.writeFile("korrtermer/test_exceljs.xlsx");
  res.end();
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

6reactions
guyonrochecommented, Dec 7, 2015

That’s because you have assigned it as a text value. To add a formula, you need to assign it like this:

// assuming 0.14 is your calculated result value
worksheet.getCell('B1').value = { formula 'A1+C1', result: 0.14 };  
1reaction
elyohan14commented, Mar 30, 2021

That’s because you have assigned it as a text value. To add a formula, you need to assign it like this:

// assuming 0.14 is your calculated result value
worksheet.getCell('B1').value = { formula 'A1+C1', result: 0.14 };  

Just a fix, worksheet.getCell(‘B1’).value = { formula: ‘A1+C1’, result: 0.14 }; instead worksheet.getCell(‘B1’).value = { formula ‘A1+C1’, result: 0.14 };

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a simple formula in Excel - Microsoft Support
You can create a simple formula to add, subtract, multiply or divide values in your worksheet. Simple formulas always start with an equal...
Read more >
Overview of formulas in Excel - Microsoft Support
Create a formula that refers to values in other cells · Select a cell. · Type the equal sign =. Note: Formulas in...
Read more >
How to Create a Formula in Excel Beginner Tutorial (2022)
Go to Formulas tab > Function Library > Insert function button > Type the function name. In the Insert Function dialog box, type...
Read more >
Formulas and Functions in Excel (Easy Tutorial)
Enter a Formula | Edit a Formula | Operator Precedence | Copy/Paste a Formula | Insert Function. A formula is an expression which...
Read more >
Add formulas & functions - Android - Google Docs Editors Help
You can use functions and formulas to automate calculations in Google Sheets. ... Tap the cell where you want to add the formula....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found