H5把页面表格数据导出到本地文件,导出为本地csv文件

本文介绍如何在H5页面中将表格数据导出为本地CSV文件。参照iview的表格导出功能,重点在于数据格式的转换,通过在列间使用逗号分隔,行间使用回车换行符连接,实现表格数据的本地保存。
摘要由CSDN通过智能技术生成

参考iview的表格导出

  1. 导出表格需要有表头数据和具体数据
//表头
let columns = [
	{
    title: '品牌', key: 'brandName' },
	{
    title: '品种', key: 'breedName' },
	{
    title: '平均零售价', key: 'avgRetailPrice' },
	{
    title: '平均批发价', key: 'avgBatchPrice' },
	{
    title: '平均成本价', key: 'avgCostPrice' },
	{
    title: '预估折扣', key: 'discount' },
	{
    title: '加盟分成', key: 'franchiseeSharing' },
	{
    title: '总部毛利率', key: 'headquartersRossInterestRate' },
	{
    title: '加盟分成金额', key: 'franchiseeSharingAmount' },
	{
    title: '总部分成金额', key: 'headquartersSharingAmount' },
	{
    title: '总部分成利润', key: 'headquartersProfits' },
	{
    title: '总部分成', key: 'headquartersSharing' },
];
//数据源
let datas = [
	{
   
       "franchiseeSharing": 0,
       "brandName": "安姿",
       "avgCostPrice": 36.1,
       "discount": 1,
       "headquartersRossInterestRate": 0.9118,
       "categoryName": "太阳镜",
       "avgBatchPrice": 44.81,
       "headquartersSharing": 1,
       "headquartersProfits": 373.25,
       "avgRetailPrice": 409.35,
       "headquartersSharingAmount": 409.35,
       "franchiseeSharingAmount": 0
   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值