【问题标题】:Tabulator, change the title of the column when exporting the tabulator table to an excel file制表器,将制表器表格导出为ex​​cel文件时更改列的标题
【发布时间】:2020-03-03 10:36:52
【问题描述】:

我有一个制表器表,我需要将其导出到 xlsx,其标题与表标题不同。 示例;

  { title: "Sub Division", field: "xxx", sorter: "string", headerFilterPlaceholder: "Filter xxx xxxx", headerFilter: "input" },

当我导出到 excel 时,我希望标题为“Sub_Division”

将制表表导出到excel文档时可以更改列的标题吗?

【问题讨论】:

    标签: tabulator


    【解决方案1】:

    是的,请参阅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/tabulator-tables@4.5.3/dist/css/tabulator.min.css" rel="stylesheet">
    <script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.5.3/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>

    【讨论】:

      猜你喜欢
      • 2016-03-09
      • 2022-01-23
      • 2021-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多