asasugar / custom-json2excel

📃 传入json生成excel,可自定义表格头部名称和过滤列
43 stars 10 forks source link

生成的表格数据重复,重复生成json数组中最后一个元素n次 #8

Closed GentlemanHu closed 3 years ago

GentlemanHu commented 3 years ago

感谢大佬提供这么方便的库。

问题如下:

比如以下数据


[
    {
        "Reporter": "꯭222",
        "ProblemDesc": "风萧萧兮易水寒",
        "Solution": "壮士一去兮不复还",
        "Image": [
            "https://*.jpg"
        ],
        "CreatedTime": "2021-04-08 22:54:57"
    },
    {
        "Reporter": "Gentleman.Hu",
        "ProblemDesc": "柳暗花明又一村",
        "Solution": "山重水复疑无路",
        "Image": [
            "https://*.jpg"
        ],
        "CreatedTime": "2021-04-08 22:53:29"
    }
]

image

var which = '问题反馈'
  keyMap = {
  Reporter: "提交人",
  ProblemDesc: "问题描述",
  Image: "解决方案",
  Solution: "相关问题图",
  CreatedTime: "提交时间"
  };

const json2excel = new Json2excel({
data: jdata,
keyMap: keyMap,
name: this.dateFormat('YYYY-mm-dd') + "_" + which,
title: [{
    name: this.dateFormat('YYYY-mm-dd') + "_" + which,
    colspan: size
}],
onStart: () => {
    uni.showLoading({
        title: '生成表格中...'
    })
},
onSuccess: () => {
    uni.showToast({
        title: '成功!请注意保存!',
        duration: 5000
    })
}

});
json2excel.generate();

就是以上代码操作,生成的xls都是重复数据 另外,能不能生成xlsx格式

GentlemanHu commented 3 years ago

重新编译了上个版本,已解决。