Excel XML Creation with Qt's Dom classes
Hi all,
I'm trying to create an Excel XML workbook ( I didn't want, but it's strictly necessary ) :crying:
I've to build an "export to Excel" option in my "very-fashioned-and-colored-grid" that runs on a linux machine, because all my users use windows as client and I have to allow them to manipulate data externally.
I have made a "CSV-export" option, but they want too the colors and some other options and they don't like to import every time ( as csv forces them to do ).
An Excel.xml file looks like this :
Code:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
...
</Workbook>
The ... zone is trivial ( simple sections easy to do with Qt's classes ), but I don't know how to generate the first 2 lines that begin with "<?".
Any idea ?
Thanks in advance,
Jordi.
Re: Excel XML Creation with Qt's Dom classes
These are called "processing instructions", so QDomDocument::createProcessingInstruction() should be the way to go.
Re: Excel XML Creation with Qt's Dom classes
Quote:
Originally Posted by
jpujolf
Hi all,
I'm trying to create an Excel XML workbook ( I didn't want, but it's strictly necessary ) :crying:
I have made a "CSV-export" option, but they want too the colors and some other options and they don't like to import every time ( as csv forces them to do ).
Any idea ?
Jordi.
have you see my first qt4 projekt...
http://sourceforge.net/projects/qtexcel-xslt/ 4000 downloads...
from xmlexcel 2003 to sqlite3
http://kent.dl.sourceforge.net/sourc.../excel2003.xsl
xml direct to excel 95
http://kent.dl.sourceforge.net/sourc...lsql2excel.xsl
xml to fop pdf
http://kent.dl.sourceforge.net/sourc.../xmlsql2fo.xsl
the fastet way is http://en.wikipedia.org/wiki/XSLT
qt4 dom have trouble if file having more as 4-5 MB
a good CSV to sqlite you can find on http://sqlitebrowser.sourceforge.net/ source...
on http://sourceforge.net/projects/visual-xsltproc/ source, i think you find more ...
lib xslt is easy on linux and mac ... on window on mingw minimal system
http://www.complex-computer.de/album...piling_libxml2
on Visual Studio i dont know....
Re: Excel XML Creation with Qt's Dom classes
I've been looking at the documentation, but I didn't see that ( I'm blind... )
Many thanks !!!! It works fine...
1 Attachment(s)
Re: Excel XML Creation with Qt's Dom classes
more simple .. you make to your client the csv export direct editable ... like the edit model tablelist from a qt book ... i attach ...
its split the csv file and make direct on a table your own excel ...
and run on all os..
Code:
QFile file("addressbook.csv");
if ( !file.
open(QIODevice::ReadOnly|QIODevice
::Text) ) return 1;
// Adressen auslesen und zeilenweise in Stringliste einlesen
// Erste Zeile (Überschriften) entnehmen und aufspalten
QString header
= records.
takeAt(0);
{
int inItem = false;
for (int pos = 0; pos < line.length(); pos++)
{
if ( c == '\"') {
if (inItem) {
items.append(item);
item = "";
}
inItem = !inItem;
}
else
if (inItem)
item += c;
}
return items;
}