We can build a sapui5 application with a simple button that executes a function import, the function import implemented in the backend will build the excel and return as binary, back again in the navigator you can offer the file to download. Here a simplified workflow:

First let’s do the odata part using the SEGW Gateway Builder and create a Complex Type ‘excel’ with reference to structure VALSTRUCTX.

Include the VAL property as binary type, in backend the type is rawstring

Then create a function import getExcel, the return type has to be the complex type we created before:

Now let’s do the implementation for the function import getExcel, just enter to the method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION and build an excel using ABAP2XLSX ( here we are using the demo12 example ):