Call the excel export in Microflow or Java Action

We all know that we can export the data in datagrid or report into an excel file very easily. But does anyone knows how to call this action from Microflow or Java action, just in case we want to generate the excel base on schedule event for example.
3 answers

You have to create a microflow activity calling a Java action. In that Java action you have to call the following method:

ExportManagerModule.generateXLS(IContext context, IMendixObject fileObject, String fileName, String oqlQuery, boolean autoSizeColumns)

This method generates an Excel file with the given filename based on the given OQL Query. The result of the OQL query will be converted into an Excel file. The resulting file will be associated to the given file object so you can download it in the AJAX client.


You can use the Core.getFileDocumentContent(IMendixObject fileDocument) function to retrieve the contents of a FileDocument as InputStream. This InputStream can be save to any location you want (and you have access to on your server) using Java. See this page for a Java example of writing an InputStream to a File.


Thanks a lot! And can I also give a path to this function to save it on a particular location e.g. other drive folder?