JS 浣跨敤xlsx.core.js 鏁版嵁瀵煎嚭鍒癳xcel

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS 浣跨敤xlsx.core.js 鏁版嵁瀵煎嚭鍒癳xcel相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/res' title='res'>res   load   col   瀵煎嚭   tle   琛ㄦ牸   date   app   moment   

/* 閫氱敤瀵煎嚭鏁版嵁  闇€瑕佸紩鍏?xlsx.core.js
    * data锛氭暟鎹?    * th锛氳〃澶?    * filename锛氬鍑鸿〃鏍煎悕绉?    */
    var data = [];
    var th = [
            ["js瀵煎嚭excel琛?, "", "", "", "", ""],
            ["鏍囬1", "鏍囬2", "鏍囬3", "鏍囬4", "鏍囬5", "鏍囬6"],
    ];
    var filename = "瀵煎嚭琛ㄦ牸鍚嶇О"锛?br>銆€銆€exportData(data, th, filename);
    function exportData(data, th, filename) {
        var deferred = $.Deferred();
        data = data || [];
        th = th || [];
        var merges = [];
        merges.push({
            s: { //s涓哄紑濮?            
                c: 0, //寮€濮嬪垪
                r: 0 //寮€濮嬭
            },
            e: { //e缁撴潫
                c: 5, //缁撴潫鍒?/span>
                r: 0 //缁撴潫琛?/span>
            }
        });
        if (data.length === 0 || th.length === 0) {
銆€銆€銆€銆€銆€銆€銆€console.log("缂哄皯鏁版嵁"); deferred.reject();
return; } filename = filename || 鈥樻暟鎹鍑衡€?span style="color: rgba(0, 0, 0, 1)">; filename
+= 鈥榑鈥?+ moment(new Date()).format(鈥榊YYYMMDDHHmmss鈥? + 鈥?xlsx鈥? // moment 鏃堕棿鎻掍欢锛堝涓嶉渶瑕侊紝鍙互鍘绘帀锛?/span> var loadedData = []; var i = 0; loadedData = loadedData.concat(th); for (i = 0; i < data.length; ++i) { var item = data[i]; var obj = []; obj.push(item.title1 || "-"); obj.push(item.title2 || "-"); obj.push(item.title3 || "-"); obj.push(item.title4 || "-"); obj.push(item.title5 || "-"); obj.push(item.title6 || "-"); loadedData.push(obj); } initFile(); function initFile() { var wb = XLSX.utils.book_new(), ws = XLSX.utils.aoa_to_sheet(loadedData); ws[鈥?merges鈥榏 = merges; // 鍚堝苟鍗曞厓鏍?/span> XLSX.utils.book_append_sheet(wb, ws, "sheet1"); XLSX.writeFile(wb, filename, { compression: true }); deferred.resolve(); } return deferred.promise(); }

 

以上是关于JS 浣跨敤xlsx.core.js 鏁版嵁瀵煎嚭鍒癳xcel的主要内容,如果未能解决你的问题,请参考以下文章

spring boot:浣跨敤澶氫釜redis鏁版嵁婧?spring boot 2.3.1)

drogon鍏ラ棬鏁欑▼涓?鎺у埗鍣ㄥ拰鏁版嵁搴撳鎴风浣跨敤

浣跨敤sessionStorage瑙e喅vuex鍦ㄩ〉闈㈠埛鏂板悗鏁版嵁琚竻闄ょ殑闂

Intel DAAL AI鍔犻€熲€斺€旀敮鎸佷粠鏁版嵁棰勫鐞嗗埌妯″瀷棰勬祴锛屾暟鎹簮蹇呴』浣跨敤DAAL鐨勫簳灞傚皝瑁呭簱

WEKA浣跨敤鏁欑▼(缁忓吀鏁欑▼杞浇)

MongoDB mongoimport 浠巆sv瀵煎叆鏁版嵁鎸囧畾瀛楁绫诲瀷