将数据长度转化为字母匹配(描述的不准确,请看下面描述)
阐述问题:在前端导出使用了vue-admin-element的方法,只要匹配好excel表格就可以合并单元格了,但是需求数据不确定,所以不能写死了,一旦数据条数增多,前端就会不断要改,所想根据自己要合并的单元个进行封装一下方法,本人数据算法较弱,尝试几个小时未能弄好,请大佬支援一下,感激不尽。
问题背景:如图
1.根据下面提供的数据生成
2.效果图片展示
相关可获得的数据:
头部数据:const theadr = ['序号','公司名称','赎回基金','申请日期','规模','巨额赎回客户','客户渠道','申请赎回量','赎回比率','基金代码'];
需要渲染的数据:
`const tdata =
[
{
"channe": "直销",
"cust": "中国银行",
"amt": "55.28",
"company": '成都有限公司',
"code": "32606",
"name":"南方通融",
"red_amt":"45.28",
"red_ratio":"9.6%",
"requt_date":"20200206",
"scale":"558",
"no":1,
},
{
"channe": "直销",
"cust": "中国银行",
"amt": "55.28",
"company": '成都有限公司',
"code": "32606",
"name":"南方通融",
"red_amt":"45.28",
"red_ratio":"9.6%",
"requt_date":"20200206",
"scale":"558",
"no":1,
},
{
"channe": "直销",
"cust": "中国银行",
"amt": "55.28",
"company": '成都有限公司',
"code": "32606",
"name":"南方通融",
"red_amt":"45.28",
"red_ratio":"9.6%",
"requt_date":"20200206",
"scale":"558",
"no":1,
},
{
"channe": "直销",
"cust": "中国银行",
"amt": "55.28",
"company": '成都有限公司',
"code": "32606",
"name":"南方通融",
"red_amt":"45.28",
"red_ratio":"9.6%",
"requt_date":"20200206",
"scale":"558",
"no":1,
},
{
"channe": "直销",
"cust": "中国银行",
"amt": "55.28",
"company": '成都有限公司',
"code": "32606",
"name":"南方通融",
"red_amt":"45.28",
"red_ratio":"9.6%",
"requt_date":"20200206",
"scale":"558",
"no":1,
},
{
"channe": "直销",
"cust": "中国银行",
"amt": "55.28",
"company": '成都有限公司',
"code": "32606",
"name":"南方通融",
"red_amt":"45.28",
"red_ratio":"9.6%",
"requt_date":"20200206",
"scale":"558",
"no":1,
},
];
`
期望结果输出:
相关链接:
1.项目展示链接:https://panjiachen.github.io/vue-element-admin/#/excel/export-merge-header
2.项目代码位置;https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/excel/merge-header.vue
正好有类似的需求,试试看