CSV file from QT
-
wrote on 19 Mar 2016, 10:51 last edited by
if I have data. For example lets say char name="Sikh";
and int old="600";
How I can create CSV file , with these value inside?
Sikh as header and 600 as value ..
Please help me how to create csv file from QT gui programming .
Thanks -
hi
something likeQString filename="c:/Data.txt"; QFile file( filename ); if ( file.open(QIODevice::ReadWrite) ) { QTextStream stream( &file ); stream << name << "," << old << endl; } file.close();
This make only one line in text file so you need a loop where you
take the name, value and write to file from your list or where u have data since
you only show 2 variables. (name, old) -
wrote on 19 Mar 2016, 11:40 last edited by
ja thanks,,,.. but I want to create csv file. (csv format excel).
-
@khalistan
hi, ok
but CSV file mean COMMA SEPARATED VALUES
and the sample create that.
sikh,600that is a CVS file. !
So you must be more clear of that the output must be.
maybe save one from exec and look in it using editor.EXEL likes to use tab instead of "," sometimes.
But again, the sample can create any type of text output you want but you
must first understand yourself what kind of format you intend to output.When that is clear to you , simple change the line
stream << name << "," << old << endl;
to match that format and you have your file.also just change
String filename="c:/Data.txt";
to
String filename="c:/Data.csv";
if u need that extension..
-
wrote on 19 Mar 2016, 11:54 last edited by
es ist gut.... danke ..... Thanks for help
-
@khalistan
super.
Keine Ursache
:)
5/6