puan-word
v1.4.5
Published
``` // 引入 import PuanWord from 'puan-word'
Downloads
89
Readme
安装:
(c)npm i puan-word -S
使用说明
// 引入
import PuanWord from 'puan-word'
// 调用
PuanWord(templateUrl, data, options)
参数说明
templateUrl:导出模板地址
data:导出数据源
options:导出配置项
options导出配置项说明
| 配置项 | 字段 | 数据类型 | 默认值 | 说明 | | ----- | ---- | ---- | ---- | ---- | | 文件名称 | filename | String | - | 可支持变量渲染如:{address} | | 压缩包名称 | zipname | String | - | 仅在data(数据源)为数组时生效 | | 默认图片尺寸 | size | Array | [160, 160] | 未配置自适应图片的默认尺寸 | | 是否开启图片尺寸自适应 | autoSize | Boolean | true | - | | 图片尺寸自适应配置 | sizeOptions | Array | - | 仅在autoSiz为true时生效 | | 公共数据 | extendsData | Object | - | 在数据处理阶段会将公共数据内容与数据源合并,可用于多文件导出的相同数据混入 | | 图片尾缀 | suffix | String | !nw-600 | - | | 错误excel | errorExcel | Object | - | 可配置错误数据excel导出内容 | | 调试模式 | debug | Boolean | false | 可以查看调试信息 |
sizeOptions格式
sizeOptions: [
{
width: 80,
keys: ['qrcode'] => qrcode字段图片将按照宽度80px,高度自适应渲染
}
]
errorExcel格式
errorExcel: {
header: [
{title: "场所id", key: "id"},
{title: "场所名称", key: "name"},
{title: "所属社区", key: "grid_text"},
{title: "场所地址", key: "address"},
]
}
常用渲染语法
注意:以下示例中a为举例变量名,实际使用中请根据真实变量名进行替换
{a} => 文本内容渲染
{-w:p a}{/a} => 循环渲染
{#a}{/a} => 1. 当a为数组时循环渲染,常用于表格(常用) 2.当a为boolean时可用于渲染判断(少用)
%a => 图片渲染