cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello UI5 Gurus,

In my view I have a table created using sap.ui.table library , I have given it a custom id "TAB2"

Now in my controller side I have written code for Downloading Table control data, I have attached screenshot.

I am getting Excel file downloaded , but its with empty contents.

Can anyone please suggest, what needs to be rectified.

Thanks,

Sijin

0 Likes
View Entire Topic
JohnPaulLiberal
Explorer
0 Likes

Hi Sijin,

Please look at the following code:

OnExcelAssets: function(oEvt){
            var oModel = this.getView().getModel("masterView");
            var oData = oModel.getData();
            var oTab = this.getView().byId("TAB2");
            var oBinding = oTab.getBinding("items");
            var oExport = new Export({
                exportType : new ExportTypeCSV({
                    separatorChar : ";"
                }),
                models : this.getView().getModel("masterView"),
                rows : {
                    path : "/myAssets",
                    filters: oBinding.aFilters
                },
                columns : [{
                    name : this.getResourceBundle().getText("actCol1"),
                    template : {
                        content : "{Anln1}"
                    }
                }, {
                    name : this.getResourceBundle().getText("actCol2"),
                    template : {
                        content : "{Txt50}"
                    }
                },{
                    name : this.getResourceBundle().getText("actCol6"),
                    template : {
                        content : "{Zzestadotxt}"
                    }    
                }]
            });
            this.onExcel(oExport);
        },

onExcel: sap.m.Table.prototype.exportData || function(oExport){
            var vText = this.getResourceBundle().getText("errorPressExcel");
            // download exported file
            oExport.saveFile().catch(function(oError) {
                //Handle your error
            }).then(function() {
                oExport.destroy();
            });
        },

Regards,

John.