2021-03-30 09:16:11 +07:00
|
|
|
# excel2json
|
|
|
|
|
2021-03-30 10:18:09 +07:00
|
|
|
[![Node.js Package](https://github.com/CUBETIQ/excel2json/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/CUBETIQ/excel2json/actions/workflows/npm-publish.yml)
|
2021-03-30 10:18:30 +07:00
|
|
|
[![Docker CI](https://github.com/CUBETIQ/excel2json/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/CUBETIQ/excel2json/actions/workflows/docker-publish.yml)
|
2021-03-30 10:18:09 +07:00
|
|
|
|
2021-03-30 09:16:11 +07:00
|
|
|
- Read file excel to json
|
|
|
|
- Custom mapping with custom columns and configs
|
2021-03-30 11:21:58 +07:00
|
|
|
- Custom props
|
|
|
|
|
|
|
|
# Install
|
|
|
|
```shell
|
|
|
|
npm i excel2json-xlsx
|
|
|
|
```
|
|
|
|
OR
|
|
|
|
```shell
|
|
|
|
yarn i excel2json-xlsx
|
|
|
|
```
|
|
|
|
OR Global Install
|
|
|
|
```shell
|
|
|
|
yarn add global excel2json-xlsx
|
|
|
|
```
|
|
|
|
Usage
|
|
|
|
```shell
|
|
|
|
excel2json-xlsx -i people.xlsx -o exported.json
|
|
|
|
```
|
2021-03-30 09:16:11 +07:00
|
|
|
|
|
|
|
# Build
|
|
|
|
|
|
|
|
```shell
|
|
|
|
bash build
|
|
|
|
```
|
|
|
|
|
|
|
|
OR
|
|
|
|
|
|
|
|
```shell
|
|
|
|
make build run
|
|
|
|
```
|
|
|
|
|
|
|
|
# Example
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run -v /my/path:/app/data --rm -it cubetiq/node-excel2json
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run -v /home/sombochea/excel2json:/app/data -e APP_NAME="EXCEL 2 JSON" -e MAPPER_FILE="./data/mapper.json" --rm -it cubetiq/node-excel2json
|
|
|
|
```
|
|
|
|
|
|
|
|
# Mapper Config
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"data": [
|
|
|
|
{
|
|
|
|
"dataIndex": "Name",
|
|
|
|
"label": "Name"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"dataIndex": "Age",
|
|
|
|
"label": "Age"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"configs": {
|
|
|
|
"outputPath": "./data/outputs/exported",
|
|
|
|
"outputName": "my_exported_data",
|
|
|
|
"sheetName": "Sheet1",
|
|
|
|
"saveToOutput": true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-30 09:18:01 +07:00
|
|
|
# Custom Function Props
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
mappings: [
|
|
|
|
{
|
|
|
|
"dataIndex": "Name",
|
|
|
|
"label": "Name"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
saveToOutput: false
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-30 09:16:11 +07:00
|
|
|
# Environment
|
|
|
|
|
|
|
|
```env
|
|
|
|
APP_NAME=custom app name
|
|
|
|
INPUT_FILE=./data/mydata.xlsx
|
|
|
|
OUTPUT_PATH=./data/outputs
|
|
|
|
MAPPER_FILE=./data/mapper.json
|
|
|
|
SHEET_NAME=Sheet1
|
|
|
|
ENCODING=utf-8
|
|
|
|
```
|