xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

CSV 不支持导出 0.0 bug All In One

CSV 不支持导出 0.0 bug All In One

[
	{
	    "Column 1": "0.0"
	},
	{
	    "Column 1": "2-1"
	},
	{
	    "Column 1": 0.0
	}
]

CSV 导出不支持 0.0,只能展示 0

    getCSVData (columns, rows) {
        const keys = columns.map(obj => obj.key);
        const result = [];
        rows.forEach((obj, i) => {
            const arr = [];
            keys.forEach(key => {
                let value = obj[key];
                if (obj[key] !== null) {
                    const format = columns.find(item => item.key === key)?.format;
                    //trend 行是偶数行,且排除 title 列
                    if(key !== 'ua_group_name') {
                        value = Utils.formats(value, (i + 1) % 2 === 0 ? 'TDF200P' : format);
                    }
                } else {
                    // value = '-';
                }
                arr.push(value);
                // arr.push(0.0);
                // arr.push('0.0');
            });
            result.push(arr);
        });
        console.log('rows', rows);
        console.log('result', result);
        return result;
    },

refs

https://www.papaparse.com/demo



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(33)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-01-19 VuePress config All In One
2021-01-19 auto deploy docs website
2020-01-19 APP 金刚区图标设计 & UI
2019-01-19 MacOS & dock 工具栏 & 外接显示器 & 主屏
点击右上角即可分享
微信分享提示