如何使用 ALASQL 和 XLSX 设置自定义 header 名称

How to set custom header names with ALASQL and XLSX

我正在使用 angularalasql[=22= 将一些 table 导出到 excel ] 和 xlsx。我按如下方式使用它:

var options = {
    headers: true,
    sheetid: 'users',
    columns: [{
      columnid: 'a',
      title: 'Username'
    }, {
      columnid: 'b',
      title: 'First name'
    }, {
      columnid: 'c',
      title: 'Last name'
    }]
  };

alasql('SELECT * INTO XLSX("test.xlsx", ?) FROM ?', [options, $scope.users]);

我期待 columnns 选项来自定义我的 table headers。但它并没有这样做。

知道为什么吗?

我设法通过使用普通 SQL:

来自定义 headers
alasql('SELECT firstName AS FirstName INTO XLSX("test.xlsx", ?) FROM ?', [options, $scope.users]);

有效,firstName 的 header 将是 FirstName。

有时您想使用 Headers 包括空格(分隔符)或...使用 headers 保留字(已删除),在这两种情况下您都可以像这样使用 [] :

alasql('SELECT firstName AS FirstName, [Deleted] AS [Erased], Separated AS [Separated By] INTO XLSX("test.xlsx", ?) FROM ?', [options, $scope.users]);