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 12:31:21 +07:00
|
|
|
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/cubetiq/excel2json)
|
|
|
|
![Docker Pulls](https://img.shields.io/docker/pulls/cubetiq/excel2json)
|
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
|
2021-03-30 12:31:21 +07:00
|
|
|
- Docker suppport
|
2021-03-30 11:21:58 +07:00
|
|
|
|
|
|
|
# Install
|
|
|
|
```shell
|
|
|
|
npm i excel2json-xlsx
|
|
|
|
```
|
|
|
|
OR
|
|
|
|
```shell
|
|
|
|
yarn i excel2json-xlsx
|
|
|
|
```
|
|
|
|
OR Global Install
|
|
|
|
```shell
|
|
|
|
yarn add global excel2json-xlsx
|
|
|
|
```
|
|
|
|
Usage
|
|
|
|
```shell
|
2021-03-30 12:31:21 +07:00
|
|
|
excel2json-xlsx -i source.xlsx -o exported.json
|
|
|
|
```
|
|
|
|
OR
|
|
|
|
```shell
|
2021-03-30 12:50:19 +07:00
|
|
|
npx excel2json-xlsx -i source.xlsx -o exported.json
|
2021-03-30 12:31:21 +07:00
|
|
|
```
|
|
|
|
|
|
|
|
# [Docker Hub](https://hub.docker.com/r/cubetiq/excel2json)
|
|
|
|
***Pulling image***
|
|
|
|
```shell
|
|
|
|
docker pull cubetiq/excel2json
|
|
|
|
```
|
|
|
|
***Run container***
|
|
|
|
```shell
|
|
|
|
docker run --rm -it -v /my/path/data:/app/data cubetiq/excel2json -i ./data/source.xlsx -p true
|
2021-03-30 11:21:58 +07:00
|
|
|
```
|
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
|
|
|
|
```
|