# @asamihsoy/xlsx2json

> Excel file to JSON file converter

Latest version **0.2.2** (published 2022-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @asamihsoy/xlsx2json
pnpm add @asamihsoy/xlsx2json
yarn add @asamihsoy/xlsx2json
bun add @asamihsoy/xlsx2json
```

Provides the command `xlsx2json`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2022-08-17 |
| First published | 2022-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 23.5 KB |
| Known vulnerabilities | 0 (+6 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | yoshimsa-yokoyama |
| Maintainers | yoshimsa-yokoyama |
| Keywords | xlsx2json, cli |

## Links

- npm: https://www.npmjs.com/package/@asamihsoy/xlsx2json
- Repository: https://github.com/yoshimsa-yokoyama/xlsx2json-cli
- Homepage: https://github.com/yoshimsa-yokoyama/xlsx2json-cli#readme
- Issues: https://github.com/yoshimsa-yokoyama/xlsx2json-cli/issues
- npm.io page: https://npm.io/package/@asamihsoy/xlsx2json

## Dependencies (6)

- [xlsx](https://npm.io/package/xlsx.md) ^0.16.9
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.2
- [inquirer](https://npm.io/package/inquirer.md) ^7.3.3
- [commander](https://npm.io/package/commander.md) ^7.0.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2022-08-17
- 0.2.1 — 2022-08-09
- 0.1.2 — 2022-03-09
- 0.1.1 — 2022-03-09
- 0.1.0 — 2022-03-09

## README

# @asamihsoy/xlsx2json

※ will be translated into English in near future

## インストール・起動方法

``` bash
npm i -D @asamihsoy/xlsx2json
npx xlsx2json ./sample.xlsx
```

※ npm scriptには `xlsx2json ./sample.xlsx -o ./assets/src/` という形で指定できます。

## 基本の使い方

xlsxファイルを用意して `xlsx2json` を実行することで、JSONへ変換できます。

##### 【INPUT】ファイル名: rostar.xlsx / シート名: member

|id|name      |company     |department|
|--|----------|------------|----------|
|1 |@asamihsoy|fugafuga Inc|division1 |
|2 |@person2  |hogehoge Inc|division2 |

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

```
npx xlsx2json ./member.xlsx
```

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

##### 【OUTPUT】ファイル名: member.json
```
{
"data": [{
    "id": 1,
    "name": "@asamihsoy",
    "company": "fugafuga Inc",
    "department": "division1"
  },{
    "id": 2,
    "name": "@person2",
    "company": "hogehoge Inc",
    "department": "division2"
  }]
}
```

---

## コマンドライン使用時のオプション確認

```
npx xlsx2json -h
```

|フラグ|必須/任意|備考                                                             |
|------|---------|-----------------------------------------------------------------|
|`-o`  |任意     |実行場所からJSONの格納ディレクトリへの相対パス                   |
|`-t`  |任意     |JSONのトップレベルオブジェクトのタイプ `array` か `object` を指定|

## その他の使い方

シート名や見出しを一定の構文で記述することで、JSONのアウトプットを操作することができます。

|アクション                      |設定箇所|設定構文                    |設定値                |説明                                                                                                                                                                                                                                                             |
|--------------------------------|--------|----------------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|JSONのトップレベルキーの変更    |シート名|`sheetName$key=altKey`      |任意の文字列          |JSONのトップレベルのキーを変更できます。（※デフォルト値は `data` です。）                                                                                                                                                                                        |
|JSONのトップレベルへのキーの追加|シート名|`!sheetName`                |マージしたいシート名  |`!`を頭につけたシートはJSON化されず、!のあとのsheetNameと同じ名前のシートのJSONのTOPレベルにマージされます。※ そのため、シート内のレコードは1行しか反映されません。                                                                                              |
|参照用途限定のシートを作成      |シート名|`__sheetName`               |参照用にしたいシート名|`__`を頭につけたシートはJSON化されず、参照用のみに使うことができます。                                                                                                                                                                                           |
|他シートの展開                  |見出し  |`jsonKey:sheetName1$ref=key`|シート名              |JSONの出力キーに`:`でシート名をつなぐことで、該当シートから生成されるJSONのキー（jsonKey）の中にシート1（sheetName1）の値を展開できます。sheetName1のデータ中でrefで指定したkeyの値がマッチするものだけが展開されます。 ※1キーに紐付けられるのは1シートのみです。|
|ネストの作成                    |見出し  |`jsonKey1.jsonKey2.jsonKey3`|キー名                |JSONの出力キーを.でつなげることで階層構造を作成可能です。かぶるキーがある場合はオブジェクトはマージされます。                                                                                                                                                    |

※ 機能は適宜追加していきます。  
※ シート名／キー名は半角英数字のみサポートしています。  
※ `!`と`__`が頭についたシートはJSONとして出力されません  
※ ~~シート名は半角英数字である必要があります。~~日本語のシート名も認識するようにしました。

---
_Source: https://npm.io/package/@asamihsoy/xlsx2json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
