xlsx2json document
Let excel express complex JSON format and export excel to json. Can be used on mac/linux/windows platform.
- To clone and run this repository you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:
# Clone this repository
git clone https://github.com/koalaylj/xlsx2json.git
# Go into the repository
cd xlsx2json
# Install dependencies and run the app
npm install && npm start
- setup config files
config.json
{
"xlsx": {
/**
* head line number.
* first line maybe comment ,second line is head line.
*/
"head": 2,
/**
* xlsx files ,glob styles.
*/
"src": "./excel/**/[^~$]*.xlsx",
/**
* path for saving JSON files
*/
"dest": "./json",
/**
* separator for array.
*/
"arraySeparator":","
}
}
- Exceute
export.bat
then./excel/*.xlsx
files will be exported to./json
directory.
id | weapon | flag | nums#[] | words#[] | bools#[] | objs#{} | obj_arr#[{}] |
---|---|---|---|---|---|---|---|
123 | shield | true | 1,2 | hello,world | true,true | a:123;b:45 | a:1;b:"hi",a:2;b:"hei" |
456 | sword | false | 3,5,8 | oh god | false,true | a:11;b:22 | a:1;b:"hello" |
Result:
[{
"id": 123,
"weapon": "shield",
"flag": true,
"nums": [1, 2],
"words": ["hello", "world"],
"bools": [true, true],
"objs": {
"a": 123,
"b": 45
},
"obj_arr": [
{"a": 1,"b": "hi"},
{"a": 2,"b": "hei"}
]
}, {
"id": 456,
"weapon": "sword",
"flag": false,
"nums": [3, 5, 8],
"words": ["oh god"],
"bools": [false, true],
"objs": {
"a": 11,
"b": 22
},
"obj_arr": [
{"a": 1,"b": "hello"}
]
}]
- number
- boolean
- string
- date
- object
- number-array
- boolean-array
- string-array
- object-array
- string:
column_name#string
- number:
column_name#number
- bool:
column_name#bool
- date:
column_name#date
. regular date formate.such asYYYY/M/D H:m:s
orYYYY-M-D
etc.. - basic type (string,number,bool):we can also leave it blank(automake type aware).
- number/boolean/string array:
column_name#[]
- object:
column_name#{}
- object array:
column_name#[{}]
Inspiring by a clojure project excel-to-json 。
- Use
;
to separate object properties。 - Only support for .xlsx format for now(do not support .xls format).