【问题标题】:ExtJS Export Excel SaveDocumentAs IssueExtJS 导出 Excel SaveDocumentAs 问题
【发布时间】:2023-03-19 05:17:02
【问题描述】:

当我尝试使用函数导出时,我在 Sencha 上收到以下错误。

我在文件中有以下内容:

   requires: [
        'AppName.view.main.MainController',
        'Ext.exporter.text.CSV',
        'Ext.grid.plugin.Exporter',
        'Ext.ux.grid.SubTable',
        'Overrides.exporter.excel.Xlsx',
    ],
    plugins: [{
        ptype: 'gridexporter'
    }],

我仍然无法导出 XLSX 文件...

错误在于:this.getView().saveDocumentAs({

代码

onExportList2: function () {
    var filters = '';
    var cm = this.getView().headerCt;

    if (cm) {
        Ext.each(cm.gridDataColumns, function(col, index) {
            var field = this.lookup(col.dataIndex + 'FilterField');
            if (field && !Ext.isEmpty(field.getValue())) {
                if (!Ext.isEmpty(filters)) filters += ', ';
                filters += col.text + ': ' + (col.exportRenderer ? col.exportRenderer(field.getValue()) : field.getValue());
            }
        }, this);
    }

    this.getView().saveDocumentAs({
        type: 'xlsx',
        title: 'Account Change',
        subtitle1: filters,
        fileName: 'Account Change Requests.xlsx'
    });
},

【问题讨论】:

    标签: extjs


    【解决方案1】:

    Overrides.exporter.excel.Xlsx 替换为Ext.exporter.excel.Xlsx

    Overrides.exporter.excel.Xlsx 在最好的情况下会改变它的行为。

    为什么崩溃很难说,除非在400 行看到MainController.js

    【讨论】:

    • 我更新了,还是报错。错误行也刚刚用它更新了我的问题。它在 saveDocumentAs 上给出错误
    • @Peace 认为原因是this.getView()。这需要是一个 ExtJS 组件;例如。 Ext.ComponentQuery.query('grid')[0](为了获得第一个数据网格的句柄 - 这可能是唯一的组件类型,将转换为 XLSX)。
    • 听起来虽然 SaveDocumentAs 没有被识别为函数...
    • @Peace 如果this 的上下文是一个数据网格,它可能是this.saveDocumentAs()
    • 仍然报错:Uncaught TypeError: this.saveDocumentAs is not a function
    【解决方案2】:

    到目前为止,我最接近找到答案的是当我对我的应用程序的一部分进行测试时,该部分已经具有此功能。我从中删除了以下代码,然后我也开始收到此错误。所以我认为这可能与网格导出器不起作用但还没有解决方案有关。

    "plugins: [{
                    ptype: 'gridexporter'
                }],"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 2016-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-25
      相关资源
      最近更新 更多