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.

Anyway to tell sheet_to_json to output with the cell's value instead of text?

See original GitHub issue

Hello!

Been using XLSX.utils.sheet_to_json, but hit a snag. The Excel workbook has a sheet with cells filled with integers. But when I run sheet_to_json, it spits them out as strings.

Using this as the example:

A2: { t: 'n', v: 1995, w: '1995' },
B2: { t: 'n', v: 27, w: '27' },
C2: { t: 'n', v: 4, w: '4' },

I assume this is because it fills out object with the cell’s text representation – w – instead of v. Is there anyway for me to tell it to use v instead?

I’m currently looping through the generated object to alter the keys I know should be numbers, but this tool would ideally not require the user to customize the converter per sheet. That could quickly get out of hand.

Thanks!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
rdmurphycommented, Feb 4, 2015

Ha, went and poked on the code, and found it pretty quickly.

XLSX.utils.sheet_to_json(worksheet, {raw: true});

It’d be good to document this!

4reactions
IgorShchcommented, Nov 18, 2015

Raw option is actually very good. It’s a shame it’s not documented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anyway to tell sheet_to_json to output with the cell's value ...
Hello! Been using XLSX.utils.sheet_to_json , but hit a snag. The Excel workbook has a sheet with cells filled with integers.
Read more >
Utility Functions - SheetJS Community Edition
aoa_to_sheet takes an array of arrays of JS values and returns a worksheet resembling the input data. Values are interpreted as follows: Numbers,...
Read more >
Format date with SheetJS - javascript - Stack Overflow
So, I figured out that passing the raw option when converting the sheet to JSON outputs all cells as a string. So it...
Read more >
Output Excel data as JSON - Office Scripts | Microsoft Learn
Learn how to output Excel table data as JSON to use in Power Automate. ... extract the hyperlink and use that instead of...
Read more >
xlsx - npm
A common problem involves generating a valid spreadsheet export from data ... format_cell generates the text value for a cell (using number ...
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