Technically, it's possible to generate Excel documents using JAVA API. But, you should first code your JAVA project ( JAR file) with the necessary lines that retrieve the desired information and you create macro that you configure to call your JAR file by setting the complete path to this file on the _ObjectFactory field:
Regarding how to code these lines, you can refer to the MEGA Exchange API.pdf for further information and get the method how to generate Excel document using an API.
PS: you need of course configure your project on Eclipse to load the mj_api.jar file in order to reuse the MEGA functions and procedure.
Mega 2009 SP5 (and possibly earlier) ships with a native Java Excel library called Aspose Cells for Java. This native Java library allows you to create Java-backed macros that can be invoked from Analysis Reports or other vehicles within Mega. Be sure to include the aspose jar file (aspose_cells_2.4.3.jar) in your Eclipse build path. You do however need to buy a development license from aspose.com. The version of the online documentation (must search the Aspose documentation archive or email Aspose support) that best aligns with the version of Aspose shipped with Mega is v2.5.4 (that is the one I use). Keep in mind that you will need to thoroughly test your code when taking a major Mega upgrade as this is a 3rd party product.