Can you create the contents of the footer using xml?
you can use next approach to attach footer from XML
… any data if necessary …
A,B,C,D
<row id=“1” …
In similar way any other command may be executed directly from XML.