我有一个制表器表,我需要以与表标题不同的标题导出到xlsx。示例;
{ title: "Sub Division", field: "xxx", sorter: "string", headerFilterPlaceholder: "Filter xxx xxxx", headerFilter: "input" },
当我导出到excel时,我希望标题为“ Sub_Division”
将制表器表导出到Excel文档时,可以更改列的标题吗?
是,请参见http://tabulator.info/docs/4.5/download
const tabledata = [{
name: "Oli Bob",
},
{
name: "Jamie Newhart",
},
{
name: "Gemma Jane",
}
];
const table = new Tabulator("#example-table", {
height: "100",
virtualDom: false,
data: tabledata,
columns: [{
title: "Row Num",
formatter: "rownum"
},
{
title: "Name",
field: "name",
downloadTitle: "Changed Name",
width: 200
},
],
});
function download() {
table.download("xlsx", "data.xlsx", {
sheetName: "MyData"
});
}
<link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
<div id="example-table"></div>
<button onclick="download()">Download Excel (with changed name)</button>