
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
excel2json
Advanced tools
Can be converted to JSON format any Excel data.
example Excel data
| A | B | C | D | |
|---|---|---|---|---|
| 1 | {} | |||
| 2 | _id | obj.code | obj.value:number | |
| 3 | ||||
| 4 | first | one | 1 | |
| 5 | second | two | 2 | |
| 6 | ||||
| converted to Object |
[
{
_id: 'first',
obj: {
code: 'one',
value: 1
}
},
{
_id: 'second',
obj: {
code: 'two',
value: 2
}
}
]
npm install excel2json
example sheet.xlsx
| A | B | C | D | |
|---|---|---|---|---|
| 1 | {name: 'Test'} | |||
| 2 | _id | obj.code | obj.value:number | |
| 3 | ||||
| 4 | first | one | 1 | |
| 5 | second | two | 2 | |
| 6 | ||||
| Sheet1 |
var excel2json = require('excel2json');
var filename = './sheet.xlsx';
var sheets = [1];
excel2json.parse(filename, sheets, function(err, data) {
console.log(data);
// [{
// num: 1, // sheet number
// name: 'Sheet1', // sheet name
// option: { name: 'Test' }, // sheet option (A1)
// contents: [
// { _id: 'first', obj: { code: 'one', value: 1 } }, { _id: 'second', obj: { code: 'two', value: 2 } }
// ]
// }]
excel2json.toJson(data, function(err, json) {
console.log(json);
// {
// Test: {
// first: {
// _id: 'first',
// obj: { code: 'one', value: 1 }
// },
// second: {
// _id: 'second',
// obj: { code: 'two', value: 2 }
// }
// }
// }
});
});
Setup options.
var excel2json = require('excel2json');
excel2json.setup({
optionCell: 'A1', // Cell with a custom sheet option. It is not yet used now. (default: 'A1'
attrLine: '2', // Line with a data attribute. (default: '2'
dataLine: '4', // Line with a data. (default: '4'
refKey: '_id' // ref key. (default: '_id'
});
sheet option. setting with optionCell (default: 'A1'
nametypekeyattrLinedataLinerefKeySpecify the key name.
Special character
# Use when the array.:number Use when the parameters of type Number.:boolean Use when the parameters of type Boolean.:date Use when the parameters of unix time.:index Use when the array of array.An example of a complex format.
var excel2json = require('excel2json');
excel2json.parse('test.xlsx', [], function(err, sheetDatas) {
excel2json.toJson(sheetDatas, function(err, result) {
fs.writeFileSync('test.json', JSON.stringifi(result, null, 4));
});
});
Run npm test and npm run-script jshint
FAQs
excel2json
We found that excel2json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.