A cli can automatically generate files from Excel files.
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
- 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
pnpm add -D unxlsx
-
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
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',
},
],
},
],
})
pnpm run unxlsx
EnTranslate
was the object that describes the information in the xlsx fileEnTranslateKeys
was the array that describes theEnTranslate
keysgetEnTranslate
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
import EnTranslate, { EnTranslateKeys, getEnTranslate } from '@/constant/EnTranslate'
//...
return (
<>
{/* normal use */}
<p>
{getEnTranslate(EnTranslateKeys.xxx1)}
</p>
{/* use slot */}
<p>
{getEnTranslate(EnTranslateKeys.xxx2, 'slot1', 'slot2')}
</p>
</>
)
sudongyuer email:[email protected]