使用tableExport導出bootstrap-table表格 支持中文的Excel等格式


$('#table').bootstrapTable('destroy').bootstrapTable({
        method: 'post',
        dataType: 'json',
        height: 560,
        toolbar: '#toolbar',               //工具按鈕用哪個容器
        pagination: true,                   //是否顯示分頁(*)
        maintainSelected: true,             //設置為 true 在點擊分頁按鈕或搜索按鈕時,將記住checkbox的選擇項
        sidePagination: "client",          //分頁方式:client客戶端分頁,server服務端分頁(*)
        pageNumber: 1,                       //初始化加載第一頁,默認第一頁
        pageSize: 10,                       //每頁的記錄行數(*)
        pageList: [10, 25, 50, 100],        //可供選擇的每頁的行數(*)
        search: true,                       //是否顯示表格搜索,此搜索是客戶端搜索,不會進服務端,所以,個人感覺意義不大
        strictSearch: false,                //設置為 true啟用 全匹配搜索,否則為模糊搜索
        showRefresh: true,                  //是否顯示刷新按鈕
        minimumCountColumns: 2,             //最少允許的列數
        clickToSelect: true,                //是否啟用點擊選中行
        sortStable: true,
 
        showExport: true,  //是否顯示導出按鈕
        buttonsAlign:"right",  //按鈕位置
        exportDataType: 'all',   //導出的方式 all全部 selected已選擇的  basic', 'all', 'selected'.
        Icons:'glyphicon glyphicon-export', //導出圖標
        exportTypes:[ 'excel','doc','xlsx','csv', 'txt', 'sql' ],  //導出文件類型 'csv', 'txt', 'sql', 'doc', 'excel', 'xlsx', 'pdf'
        exportOptions:{
            // ignoreColumn: [0,1],  //忽略某一列的索引
            fileName: questionNaireName,  //文件名稱設置
            worksheetName: 'sheet1',  //表格工作區名稱
            tableName: questionNaireName,
            // excelstyles: ['background-color', 'color', 'font-size', 'font-weight'], 設置格式
        },
 
 
 
    });

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM