PDA

View Full Version : Using QTextDocumentWriter to write a spreadsheet in ODF



DrDonut
16th October 2009, 12:51
Hi all,

A program I am writing gets data that need to be written in a spreadsheet. This spreadsheet would be preferably in the ODF-format, so the user can choose multiple programs to view/edit this file.

The standard extension for the ODF spreadsheet format is ".ods"

Now, in QT 4.5 there is the QTextDocumentWriter class that can be used to write documents in the ODF document format (".odt").

So my question is: Can this class also be used to write spreadsheet files instead of text files? Or is there some other qt-class for this that I don't yet know about?

Thanks in advance!

DrDonut

Kumosan
17th October 2009, 20:15
So my question is: Can this class also be used to write spreadsheet files instead of text files? Or is there some other qt-class for this that I don't yet know about?

No and no.

Lykurg
17th October 2009, 21:14
Or is there some other qt-class for this that I don't yet know about?

Well, the ODF spreadsheet format is simple XML. So you can use QFile, QDomDocument or QXmlStreamWriter to achieve your goal. This, of course, needs that you write the xml yourself, but that's not so a big deal.

DrDonut
18th October 2009, 13:25
Thanks for your reply's:)

So I guess I can start reading the ODF-specifcation and write it all like XML-files.

Lykurg
18th October 2009, 13:27
So I guess I can start reading the ODF-specifcation and write it all like XML-files.

Well, I was too lazy for that, so I create a sample file. Then only grab the content.xml and edited that with my new values. That is easier than creating the whole package from the scratch.