溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

bootstrap中怎么導出表格

發(fā)布時間:2021-07-23 14:19:40 來源:億速云 閱讀:153 作者:Leah 欄目:開發(fā)技術(shù)

bootstrap中怎么導出表格,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

點擊home按鈕進入github官方文檔,會看到導出使用的插件是bootstrap-table-export.js  ,而這個插件中使用的是tableExport.jquery.plugin插件。后者是一個獨立的表格導出插件。

而前者是經(jīng)過bootstrap官方將后者與bootstrap表格進行了完美的整合之后的插件。所以我們只需要使用前者即可。

<script src="extensions/export/bootstrap-table-export.js"></script>

下面直接貼代碼:

 //查詢    function refresh(){        $("#datatable").bootstrapTable('refresh',{url:'__MODULE__/Statistics/listData'});    }    //查詢條件    function queryParams(params){        params['project_id'] = $("select[name=project_id]").find("option:selected").val();        params['time_field'] = $("select[name=time_field]").find("option:selected").val();        params['start_time'] = $("input[name=start_time]").val();        params['end_time'] = $("input[name=end_time]").val();        params['user_name'] = $("input[name=user_name]").val();        params['telephone'] = $("input[name=telephone]").val();        params['room_confirm_number'] = $("input[name=room_confirm_number]").val();        params['lineson'] = $("select[name=lineson]").val();        params['invoice'] = $("select[name=invoice]").val();        return params;    }      function DoOnMsoNumberFormat(cell, row, col) {        var result = "";        if (row > 0 && col == 0)            result = "\\@";        return result;    }    var rowCount = 0;    $("#datatable").bootstrapTable({        height:"500",        url: '__MODULE__/Statistics/listData',  //表格數(shù)據(jù)請求地址        pagination:true,   //是否分頁        search: false,    //是否顯示查詢框        sortName: "id",    //排序相關(guān)        sortOrder: "desc",        queryParams:'queryParams',        method:"post",        sortable:true,        dataType:'json',        toolbar: "#exampleTableEventsToolbar",        icons: {refresh: "glyphicon-repeat", toggle: "glyphicon-list-alt", columns: "glyphicon-list"},        pageList:[10, 25, 50, 100],        clickToSelect:true,        exportDataType:'all',         onLoadSuccess:function(data){   //表格數(shù)據(jù)加載成功事件            rowCount = data.length-1;            $("#datatable").bootstrapTable('hideRow', {index:rowCount});            $("#datatable td").attr("data-tableexport-msonumberformat","\@");            $("#datatable tr").attr("data-tableexport-display","always");        },        onPageChange:function(number,size){  //表格翻頁事件            $("#datatable").bootstrapTable('hideRow', {index:rowCount});            $("#datatable td").attr("data-tableexport-msonumberformat","\@");            $("#datatable tr").attr("data-tableexport-display","always");         },        showExport: true,  //是否顯示導出按鈕        buttonsAlign:"right",  //按鈕位置        exportTypes:['excel'],  //導出文件類型        Icons:'glyphicon-export',        exportOptions:{            ignoreColumn: [0,1],  //忽略某一列的索引            fileName: '總臺帳報表',  //文件名稱設(shè)置            worksheetName: 'sheet1',  //表格工作區(qū)名稱            tableName: '總臺帳報表',            excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],            onMsoNumberFormat: DoOnMsoNumberFormat        },        columns: [            {                checkbox:true,                title: '選擇'            },{                title: '序號',                formatter: function (value, row, index) {                    $(".group_sum").html(row['group_sum']);                    $(".group_money_sum").html(row['group_money_sum']+"元");                    $(".confirm_sum").html(row['confirm_sum']);                    $(".confirm_money_sum").html(row['confirm_money_sum']+"元");                    $(".refund_sum").html(row['refund_sum']);                    $(".refund_money_sum").html(row['group_back_sum']+"元");                    $(".residue_money_sum").html(row['residue_sum']+"元");                    var a = index+1; return a+"<span style='display:none;'>"+row.id+"</span>"                }            },{                field: 'project_name',                align:"center",                title: '項目'            }, {                field: 'user_name',                align:"center",                title: '姓名'            }, {                field: 'telephone',                align:"center",                title: '電話'            },{                field: 'id_card_number',                align:"center",                rowAttributes:"rowAttributes",                title: '身份證號'            },{                field: 'telephone',                align:"center",                title: '手機號'            },{                field: 'pos_r_n',                align:"center",                title: 'POS機參考號'            },{                field: 'pos_c_n',                align:"center",                title: 'POS機終端號'            },{                field: 'merchant_code',                align:"center",                title: '商戶編碼'            },{                field: 'bank_card_number',                align:"center",                title: '銀行卡號'            },{                field: 'create_time',                align:"center",                title: '領(lǐng)取優(yōu)惠時間'            },{                field: 'group_purchase_number',                align:"center",                title: '優(yōu)惠編碼'             },{                field: 'group_purchase_expenses',                align:"center",                title: '會員費用'            },{                field: 'back_pay_money',                align:"center",                title: '退款金額'            },{                field: 'refund_etime',                align:"center",                title: '退款時間'            },{                field: 'confirm_pay_money',                align:"center",                title: '認購金額'            },{                field: 'group_purchase_confirm_time',                align:"center",                title: '認購時間'            },{                field: 'room_confirm_number',                align:"center",                title: '認購房號'            },{                field: '',                align:"center",                title: '賬戶余額'            },{                field: 'invoice_status',                align:"center",                title: '發(fā)票狀態(tài)',                formatter: 'invoice_status_formatter',                events:'confirmEvents'            },{                field: 'lineson',                align:"center",                title: '數(shù)據(jù)來源',                formatter: 'lineson_status_formatter',                events:'confirmEvents'            }        ]    });

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI