... but might as well be interfaced directly by a Java class as part of a broader [yet non commercial] software.
It handles attributes, repeated elements, and so on, and produces results which level up with what spreadsheets generate when they import native XML (at least in its most extensive execution mode).
Please refer to the documentation for further details (PDF doc, Open Office Writer doc, and API doc).
This free software is released under the GNU GENERAL PUBLIC LICENSE Version 3.