# @silencesys/xlsx-to-xml

> Export XLSX files to XML

Latest version **1.0.3** (published 2021-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @silencesys/xlsx-to-xml
pnpm add @silencesys/xlsx-to-xml
yarn add @silencesys/xlsx-to-xml
bun add @silencesys/xlsx-to-xml
```

Provides the command `xlsx-to-xml`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-11-11 |
| First published | 2021-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Martin Roček |
| Maintainers | silencesys |
| Keywords | xlsx, xml, spreadsheet, excel, exporter |

## Links

- npm: https://www.npmjs.com/package/@silencesys/xlsx-to-xml
- Repository: https://github.com/silencesys/dh--xlsx-to-xml
- Homepage: https://github.com/silencesys/dh--xlsx-to-xml#readme
- Issues: https://github.com/silencesys/dh--xlsx-to-xml/issues
- npm.io page: https://npm.io/package/@silencesys/xlsx-to-xml

## Dependencies (3)

- [xlsx](https://npm.io/package/xlsx.md) ^0.17.2
- [yargs](https://npm.io/package/yargs.md) ^17.2.1
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.10

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-11-11
- 1.0.2 — 2021-11-10
- 1.0.1 — 2021-11-10
- 1.0.0 — 2021-11-10

## README

# XLSX to XML

This little tool converts two column XLSX Excel files to XML.

<br>

## How to use

1. Install this package with NPM
```bash
npm install -g @silencesys/xlsx-to-xml
```
2. Create config file that will be used for the transformation
3. Run the tool
```bash
xlsx-to-xml --input your_input_file.xlsx --output your_output_file.xml --config your_config.json
```

<br>

### Available options
| Option | Description |
| ------ | ----------- |
| --input, -i | The input file to be converted to xlsx |
| --output, -o | The output file to be created |
| --config, -c | The config file that will be used |
| --dirty | Set this flag if you want to see XHTML tags added by XLSX transformer |
| --ignore-halves | Set this flag if you want to ignore rows that has one column empty |
| --help, -h | Show help |

<br>

## Config file
The config file is a standard JSON file with following structure:
```json
{
  "parentTagName": "dictionary",
  "rowTagName": "entry",
  "language": ["eng", "cze"],
  "stripTags": [
    "<span style=\"font-size:12pt;\">"
  ],
  "replaceTags": [
    {
      "from": "<span style=\"font-size:9pt;\">",
      "to": "<note>"
    },
  ],
  "divideBy": [
    [": "]
  ]
}
```
As you can see there are several options that can be used. **There is no default config file as each use case is expected to be unique.** You can use aforementioned snippet as your default config file.

| Option | Required | Description |
| ------ | :--: | ----------- |
| `parentTagName` | Yes | Name of the parent tag. |
| `rowTagName` | Yes | Name of the row tag. |
| `language` | Optional | List of languages that should be used. |
| `stripTags` | Optional | List of tags that should be stripped from the text. The list should contain only opening tags with all their attributes that should be removed. |
| `replaceTags` | Optional | List of tags that should be replaced. These tags should always be defined as a JSON object containing keys `from` and `to`. Only opening tags but with all attributes should be defined there. |
| `divideBy` | Optional | List of strings that should be used to divide the text. _You might want to include spaces following after these characters as the division method is quite dumb_.  |

<br>

### How to write a config file
I'm sure you ask how am I supposed to know which XHTML tags will be used in my XLSX document after conversion. Well, for that purpose there is a very simple way. Just run following command:
```bash
xlsx-to-xml --input your_input_file.xlsx --dirty
```
This will output a _dirty_ file containing XML with all XHTML tags. You can then decide which tags should be stripped or replaced and which should be kept. Just keep in mind that tags `<dirty-list>` and `<dirty-row>` are added by this tool and will be replaced by `parentTagName` and `rowTagName` respectively.

<br>

## Contributing
All the code is open source and you can contribute to the project by creating pull requests.

<br>

## License
This project is licensed under the [MIT license](LICENSE.md).

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