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.

Option to output formulae to JSON

See original GitHub issue

I’m using .sheet_to_json for easier testing (instead of comparing the ws object with an expected one). The problem is that formula cells don’t show up in the JSON output. Is there a way to make that happen (other than sheet_to_formulae)? If not, an option like formulas: true for sheet_to_json would be very useful for test automation.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Antonio-Gonzalez-Gomezcommented, Jul 4, 2022

For anyone still looking for this, I’m using a function based on @Mithgol algorithm from #270 with some tweaks:

workbook.SheetNames.forEach(function(name) {
   const sheet = workbook.Sheets[name];
   const range = XLSX.utils.decode_range(sheet['!ref']);
   const json = [];
   var row;
   var rowNum;
   var colNum;
   for(rowNum = range.s.r; rowNum <= range.e.r; rowNum++){
       row = [];
       for(colNum = range.s.c; colNum <= range.e.c; colNum++){
           var nextCell = sheet[XLSX.utils.encode_cell({r: rowNum, c: colNum})];
           if( typeof nextCell === 'undefined' ){
               row.push(void 0);
           } else {
               const value = nextCell.f ? "=" + nextCell.f : nextCell.v; //change this line if needed
               row.push(value);
           }
       }
       json.push(row);
   }
   //do stuff with the json
});
1reaction
leostar-evacommented, Oct 14, 2019

I also met the same problem. Has this problem been solved?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Output Excel data as JSON - Office Scripts | Microsoft Learn
Excel table data can be represented as an array of objects in the form of JSON. Each object represents a row in the...
Read more >
How to Convert HTML Form Field Values to a JSON Object
preventDefault(); // TODO: Call our function to get the form data. const data = {}; // Demo only: print the form data onscreen...
Read more >
JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or ...
Read more >
Using outputs() function and JSON Parse to read data from ...
outputs () function · Take Parse JSON action from Data Operations in a Flow · In that in Inputs, you can use Function...
Read more >
How to store a javascript function in JSON - Stack Overflow
In the general case, you can't. · "(And creating my own Lexer-Parser to interupt string function I dont think is an option)" Well,...
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