excel2json/README.md

111 lines
2.1 KiB
Markdown
Raw Normal View History

# 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)
![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
- Read file excel to json
- Custom mapping with custom columns and configs
2021-03-30 11:21:58 +07:00
- Custom props
- 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
excel2json-xlsx -i source.xlsx -o exported.json
```
OR
```shell
npx excel2json -i source.xlsx -o exported.json
```
# [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
```
# 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
}
}
```
# Custom Function Props
```javascript
{
mappings: [
{
"dataIndex": "Name",
"label": "Name"
}
],
saveToOutput: false
}
```
# 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
```