xlsx to JSON parser. Also support i18next format. Relies on node-xlsx.
- v.0.3.5 - Update Readme.md
- v.0.3.4 - Improve recursiveSearchValues & update tests
- v.0.3.3 - Update Readme.md
- v.0.3.2 - Fix known issues with one level template
- v.0.3.1 - Update Readme.md
- v.0.3.0 - Add config tests. Fix parser. Now it's work as NPM module correctly
- v.0.2.5 - Codystyle fixes
- v.0.2.4 - Remove async write file & some refactoring
- v.0.2.3 - Add author's contacts
- v.0.2.2 - Add jest testing
- v.0.2.1 - Refactoring
- v.0.2.0 - Add append to exist files
- v.0.1.0 - First init
npm i xlsx-json-parser
Then add folder xlsx
(you can change it in xlsx-json-parser.config.js) in your project folder
node node_modules/xlsx-json-parser
"scripts": {
"xlsx-parse": "node node_modules/xlsx-json-parser"
}
And when you need to parse xlsx type in your console npm run xlsx-parse
node node_modules/xlsx-json-parser --ln=listNumber --xlsx=xlsxDir --json=jsonDir --wfn
--ln
- List number
--xlsx
- Path to xlxs
--json
- Path to json
--wfn
- With file names for json files
You can change default arguments in xlsx-json-parser.config.js
Config file xlsx-json-parser.config.js
looks like
const config = {
xlsxDir: 'xlsx',
jsonDir: 'json',
listNumber: 1,
withFilenames: false,
fileTemplate(lang, array) {
return `{
"${lang}": {
"translations": ${JSON.stringify(array)}
}
}`;
},
};
module.exports = config;
You can overwrite it by put xlsx-json-parser.config.js
to your directory
xlsxDir
- default folder with xlsx files
jsonDir
- default folder for json files
listNumber
- Number of needed list in Excel file
withFilenames
- Add to json files name of xlsx files if false, json files will be overwritten
fileTemplate
- method for set how json might looks, where lang
- is current language for file, array
- items for this langugae
By default keys for all langs parser get value from first lang
{
"lang": {
"translations": {
"key": "value",
"another_key": "another value"
}
}
}
You can change format in xlsx-json-parser.config.js
Parser looks into xlsxDir
and parse all xls/xlsx files.
Return filenames looks like {lang}_{xlsxFileName}.json
To correct parsing you need next format - First row in xlsx file is for languages. Rows are for keys and values.
Yep! It can be append to exist files if your JSON file format in config equal to your exist JSON view.
If you write next template
fileTemplate(lang, array) {
return `{
"${lang}": ${JSON.stringify(array)}
}`;
}
You recieve
{
"lang": {
"key": "value",
"another_key": "another value"
}
}
If you write next template
fileTemplate(lang, array) {
return `${JSON.stringify(array)}`;
}
You recieve
{
"key": "value",
"another_key": "another value"
}