Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 35f3f4d

Browse files
authored
Merge pull request #71 from cgdobre/fix-#70-xlsx-cell-types
fix issue #70 - numeric cells showing up as strings in xlsx output
2 parents 73f4dce + 1864ced commit 35f3f4d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/output/xlsx.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ class xlsx extends Base {
8787
toStdOut() {
8888
Cli.error(`Can't output xlsx to std out`);
8989
}
90+
91+
/**
92+
* prepare the given object by converting numeric
93+
* columns/properties as numbers instead of strings
94+
* on top of what the parent method already does
95+
*
96+
* suboptimally done here to avoid impacts on other outputs
97+
*
98+
* @param obj
99+
* @param columns
100+
* @returns {Array}
101+
*/
102+
prepare(obj = {}, columns = []) {
103+
let formattedObj = super.prepare(obj, columns);
104+
return formattedObj.map(field => isNaN(field) ? field : Number(field));
105+
}
90106
}
91107

92108
module.exports = xlsx;

0 commit comments

Comments
 (0)