<Page title="XML" showHeader="false" floatingFooter="true">
<footer>
<Bar design="sap.m.BarDesign.Footer">
<contentRight>
<Button icon="sap-icon://excel-attachment" press="exportxls" />
</contentRight>
</Bar>
</footer>
<content>
<Table id="idtable" growing="true" growingThreshold="50">
<columns>
<Column width="8em">
<Text text="Purchasing Doc." />
</Column>
<Column>
<Text text="Purchasing Doc. Category" width="6em"/>
</Column>
<Column>
<Text text="Purchasing Doc. Type" width="6em"/>
</Column>
<Column>
<Text text="Status" />
</Column>
<Column>
<Text text="Created on" />
</Column>
<Column>
<Text text="Created by" />
</Column>
</columns>
</Table>
</content>
</Page>
onInit : function() {
//* Create ODATA model
var url = "/sap/opu/odata/SAP/<service>/";
oModel = new sap.ui.model.odata.ODataModel(url, true);
//* Create Items Aggregation for Table
this.getView().byId("idtable").bindAggregation("items", "/<EntitySet>",
new sap.m.ColumnListItem({
cells : [
new sap.m.Text({
text: "{Ebeln}"
}),
new sap.m.Text({
text : "{Bstyp}"
}),
new sap.m.Text({
text : "{Bsart}"
}),
new sap.m.Text({
text : "{Statu}"
}),
new sap.m.Text({
text : "{Aedat}"
}),
new sap.m.Text({
text : "{Ernam}"
})
]
}));
//* Set ODATA Model to Table
this.getView().setModel(oModel);
this.getView().byId("idtable").setModel(oModel);
exportxls: sap.m.Table.prototype.exportData || function(oEvent) {
var oExport = new sap.ui.core.util.Export({
exportType : new sap.ui.core.util.ExportTypeCSV({
separatorChar : ";"
}),
models : this.getView().getModel(),
rows : {
path : "/<EntitySet>"
},
columns : [
{
name : "Purchasing Doc.",
template : {
content : "{Ebeln}"
}
}, {
name : "Purchasing Doc. Category",
template : {
content : "{Bstyp}"
}
}, {
name : "Purchasing Doc. Type",
template : {
content : "{Bsart}"
}
}, {
name : "Status",
template: {
content: "{Statu}"
}
}, {
name: "Created on",
template: {
content: "{Aedat}"
}
}, {
name: "Created by",
template: {
content: "{Ernam}"
}
}
]
});
//* download exported file
oExport.saveFile().always(function() {
this.destroy();
});
exportxls: sap.m.Table.prototype.exportData || function(oEvent) {
var oExport = new sap.ui.core.util.Export({
exportType : new sap.ui.core.util.ExportTypeCSV({
separatorChar: "\t",
mimeType: "application/vnd.ms-excel",
charset: "utf-8",
fileExtension: "xls"
}),
models : this.getView().getModel(),
rows : {
path : "/<EntitySet>"
},
columns : [
{
name : "Purchasing Doc.",
template : {
content : "{Ebeln}"
}
}, {
name : "Purchasing Doc. Category",
template : {
content : "{Bstyp}"
}
}, {
name : "Purchasing Doc. Type",
template : {
content : "{Bsart}"
}
}, {
name : "Status",
template: {
content: "{Statu}"
}
}, {
name: "Created on",
template: {
content: "{Aedat}"
}
}, {
name: "Created by",
template: {
content: "{Ernam}"
}
}
]
});
//* download exported file
oExport.saveFile().always(function() {
this.destroy();
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
12 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |