https://github.com/sudongyuer/unxlsx
🌸 A cli can automatically generate files from Excel files.
https://github.com/sudongyuer/unxlsx
cli excel generator xlsx
Last synced: over 1 year ago
JSON representation
🌸 A cli can automatically generate files from Excel files.
- Host: GitHub
- URL: https://github.com/sudongyuer/unxlsx
- Owner: sudongyuer
- License: mit
- Created: 2022-07-11T16:23:53.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-29T17:02:04.000Z (almost 4 years ago)
- Last Synced: 2025-03-18T23:44:24.460Z (over 1 year ago)
- Topics: cli, excel, generator, xlsx
- Language: TypeScript
- Homepage:
- Size: 170 KB
- Stars: 25
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# unxlsx
A cli can automatically generate files from Excel files.
[](https://www.npmjs.com/package/unxlsx)
## Why
We often need to export some information from `XLSX` to generate our files, such as `multi-language`, such as `error message copywriting`, such as project `translation copywriting`, when we need `unxlsx` to help us automatically generate
## Features
- Multiple xlsx support
- Custom filed key support
- Custom filed value support
- Automatic generation of files if the file does not exist
- Typescript support config file
- ✨ support `{}` slot in the filed value
## Usage
### Install
```bash
pnpm add -D unxlsx
```
### Config `generate.config.ts`
- xlsxDir (require) : xlsx file directory base on `process.cwd()`
- files (require) : all the files you want to generate
- key (require) : the key in the xlsx file
- value (require) : the value in the xlsx file
- outPutFileDir (require) : the file you want to generate to
```js
import { defineGenerateConfig } from 'unxlsx/utils'
export default defineGenerateConfig({
xlsxDirs: [
{
xlsxDir: './xxx1.xlsx',
files: [
{
key: 'key1',
value: 'value1',
outPutFileDir: './src/generate/file1.ts',
},
{
key: 'key2',
value: 'value2',
outPutFileDir: './src/generate/file2.ts',
},
],
},
{
xlsxDir: './xxx2.xlsx',
files: [
{
key: '后端接口错误码',
value: '中文文案对照',
outPutFileDir: './src/generate/file3.ts',
},
{
key: '后端接口错误码',
value: '英文文案',
outPutFileDir: './src/generate/file4.ts',
},
],
},
],
})
```
### Generate `.ts`
```bash
pnpm run unxlsx
```
### UseSlot Demo
- `EnTranslate` was the object that describes the information in the xlsx file
- `EnTranslateKeys` was the array that describes the `EnTranslate` keys
- `getEnTranslate` you can get the value you want to use in the file
- `@/constant/EnTranslate` was the directory of the generated file directory
- above code all generated by unxlsx
`In react jsx`
```jsx
import EnTranslate, { EnTranslateKeys, getEnTranslate } from '@/constant/EnTranslate'
//...
return (
<>
{/* normal use */}
{getEnTranslate(EnTranslateKeys.xxx1)}
{/* use slot */}
{getEnTranslate(EnTranslateKeys.xxx2, 'slot1', 'slot2')}
>
)
```
## Author
sudongyuer email:976499226@qq.com
## License
[MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer)