制表符-将表导出到xlsx

时间:2019-03-05 10:33:34

标签: tabulator

表标题导出到excel时没有格式。

尝试使用文档中的示例表之一。

问题:是否可以设置表格标题的格式,使它们在excel中以粗体显示?如果可以,该怎么做?

html

<button id="download-xlsx">Excel</button>
<div id="example-table"></div>

javascript

var tabledata = [
     {id:1, name:"Oli Bob", age:"12", col:"red", dob:""},
     {id:2, name:"Mary May", age:"1", col:"blue", dob:"14/05/1982"},
     {id:3, name:"Christine Lobowski", age:"42", col:"green", dob:"22/05/1982"},
     {id:4, name:"Brendon Philips", age:"125", col:"orange", dob:"01/08/1980"},
     {id:5, name:"Margret Marmajuke", age:"16", col:"yellow", dob:"31/01/1999"},];

var table = new Tabulator("#example-table", {
    height:205, 
    data:tabledata, 
    layout:"fitColumns", 
    columns:[ 
        {title:"Name", field:"name", width:150},
        {title:"Age", field:"age", align:"left", formatter:"progress"},
        {title:"Favourite Color", field:"col"},
        {title:"Date Of Birth", field:"dob", sorter:"date", align:"center"},
    ],

});

$("#download-xlsx").click(function(){
        table.download("xlsx", "data.xlsx");
});

0 个答案:

没有答案