Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix issue #70 - numeric cells showing up as strings in xlsx output
  • Loading branch information
cgdobre committed Sep 22, 2018
commit 1864ced58c1d2d8bd92b54fb631bbc3b68813160
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/output/xlsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ class xlsx extends Base {
toStdOut() {
Cli.error(`Can't output xlsx to std out`);
}

/**
* prepare the given object by converting numeric
* columns/properties as numbers instead of strings
* on top of what the parent method already does
*
* suboptimally done here to avoid impacts on other outputs
*
* @param obj
* @param columns
* @returns {Array}
*/
prepare(obj = {}, columns = []) {
let formattedObj = super.prepare(obj, columns);
return formattedObj.map(field => isNaN(field) ? field : Number(field));
}
}

module.exports = xlsx;