To write out data to Excel -- yOu need to write a custom service that uses Excel API. It does not matter where the data comes from - a relational database, the JCR, etc, You still need to write an AEM Service that uses the Excel API as specified in that link that Ranta provided. AEM does not offer an OOTB Excel endpoint.