xlsxParser (English Document)
Convert complex excel into the json you want
- Currently only.xlsx format is supported。
- This project is based on nodejs. Please install the nodejs environment first。
- Execute the command
# Clone this repository
git clone https://github.com/sliencio/xlsxParser.git
# Go into the repository
cd xlsxParser
# Install dependencies
npm install
- 配置config.json
{
"xlsx": {
//Type in line
"typeRow":2,
//Line of title
"headRow": 3,
//xlsx path
"src": "./excel/**/[^~$]*.xlsx",
//output path
"outPath": "./json",
//array separator
"arrayFlag":",",
//The join symbol of a subtable
"sonCon": ".",
//Sibling table join symbol
"brotherCon": "&"
},
"json": {
//is compression json
"compress": false
}
}
bash export.sh
Double-click on export. Bat
Read . / excel /
all XLSX file path, export to path . / json /
, json file named after the name sheet
The output is as follows (item.extro :) : (sibling table: item&brother) {array subtable item.attrs}
{
"1001": {
"id": "1001",
"Des": "这是机枪",
"name": "机枪",
"attack": 150,
"expAdd": 10,
"extro": {
"id": "1001",
"extro": "机枪的额外属性"
},
"attrs": [
{
"id": "1001",
"value": 10,
"name": "名称1"
},
{
"id": "1001",
"value": 15,
"name": "名称2"
},
{
"id": "1001",
"value": 20,
"name": "名称3"
},
{
"id": "1001",
"value": 25,
"name": "名称4"
},
{
"id": "1001",
"value": 30,
"name": "名称5"
},
{
"id": "1001",
"value": 35,
"name": "名称6"
}
],
"life": 200
}
}
number
numeric types.Boolean
Boolean.string
string.date
date type.object
object, consistent with JS object.array
array, consistent with JS array.id
primary key type (when the table has id type, as to the hash json format output, or output) in an array format.id []
primary key array, is only found in from the table.
- when basic data types (string,number,bool) are set, they are generally not automatically judged, but data types can also be explicitly declared.
- string type: named form
column name string
. - numeric types: named form
column number
. - date type:
column date
. The date format should conform to the standard date format. Such asYYYY/M/D H: M: s
orcolumn bool
. - array: named form
column names []
. - object: named form
column {}
. - primary key: named form
column id
, there can be only one column in the table. - : the primary key array named form
column id []
, there can be only one column in the table, only exist in from the table. - column name to
!
beginning do not export.
- the sheet name to
!
beginning do not export the table. - table from the table name
name
.child table
the main table name
& table
- the key symbols are all English half Angle symbols, which are consistent with JSON requirements.
- object writing is the same as object writing in JavaScript
- arrays are written the same way as arrays are written in JavaScript
- run on Windows/MAC/Linux.
- project address [xlsxParser] (https://github.com/sliencio/xlsxParser)