简体   繁体   English

如何在 Tabulator 的 XLS 导出中设置列宽

[英]How to set the column width in Tabulator's XLS export

I am using Tabulator as frontend table framework.我使用Tabulator作为前端表框架。 When I download the table data in Excel file format , my columns have default size.当我以Excel 文件格式下载表格数据时,我的列具有默认大小。 Is it possible to set the width of columns in xls file?是否可以在 xls 文件中设置列的宽度? I need the columns to be the same size as in the table in the browser.我需要列的大小与浏览器中表格的大小相同。

Excel spreadsheet and Tabulator are not the same thing so if will be difficult to set up a one to one relationship between them. Excel 电子表格和 Tabulator 不是一回事,因此很难在它们之间建立一对一的关系。 You could set up column widths in your table constructor using these settings .您可以使用这些设置在表构造函数中设置列宽。 There is also the fit data options .还有拟合数据选项

I found a solution how to set column widths using sheetjs我找到了一个如何使用 sheetjs 设置列宽的解决方案

  table1.download("xlsx", "data.xlsx", {
    documentProcessing: function(workbook) {

      var ws_name = workbook.SheetNames[0];
      var ws = workbook.Sheets[ws_name];
      
      // setting column with in characters (use wpx for pixels)
      var wscols = [
          {wch:60},
          {wch:7},
          {wch:10},
          {wch:200}
      ];

      ws['!cols'] = wscols;

      return workbook;
    },
  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM