Results 1 to 4 of 4

Thread: Data exporting to Excel error

  1. #1
    Join Date
    Dec 2010
    Posts
    41
    Thanks
    12

    Default Data exporting to Excel error

    Hello friends i have a small problem. I have some data which i store into a sqlite data base.. Which i export to a excel file. Now i am able to export the selected channels but the excel file does't get updated.. Only the column names and one row of temperature data is updated after that the data is not updated into the excel file. It shows empty with only one row of data.. This is my code

    Qt Code:
    1. if(newfiles==0)
    2. {
    3. newfilename = "E:/"+ QDateTime::currentDateTime().toString("ddd dd-MM-yyyy, hh.mm") +".xls";
    4. newfiles++;
    5. }
    6. file4 = new QFile(newfilename);
    7. file4->open(QFile::ReadWrite | QFile::Text);
    8.  
    9. QSqlQuery sq1("SELECT "+ colames +" FROM thdata where rowid = " + QString::number(rowcnt1));
    10. while(sq1.next())
    11. {
    12. for (int i = 0; i < colames.size(); i++)
    13. {
    14. tpdata.push_back(sq1.value(i).toString());
    15.  
    16. }
    17. }
    18. QTextStream out4(file4);
    19.  
    20. for(int d = 0;d < tempchnames.count();d++) //Selected Channel Names
    21. {
    22. out4 << tempchnames.at(d);
    23. out4 <<'\t'<<'\t' ;
    24. }
    25. out4 << "Time";
    26. out4 <<'\t'<<'\t' ;
    27.  
    28. out4 <<"\n" <<"";
    29. for(int j=0; j< tpdata.count(); j++) // Selected Channel Data
    30. {
    31. out4 << tpdata.at(j);
    32. out4 <<'\t'<<'\t' ;
    33. }
    34.  
    35. }
    36. QTextStream out1(file4);
    37. while(!out1.atEnd())
    38. {
    39. QStringList list2;
    40. QString line2 = out1.readLine();
    41. list2 = line2.split("\n");
    42. }
    43. }
    To copy to clipboard, switch view to plain text mode 
    dont know what i am doing wrong the data is not been updated after the first row. ??

    thank you

  2. #2
    Join Date
    Dec 2010
    Posts
    41
    Thanks
    12

    Default Re: Data exporting to Excel error

    Hey i solved my problem.. in case some body new with excel file export from sqlite db, i can give u working code of what i wrote..

    regards

  3. #3
    Join Date
    Feb 2009
    Posts
    7
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Data exporting to Excel error

    Rex,
    I am very interested in working with excel files, so could you send to me some "working code".

    Thanks,

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Data exporting to Excel error

    Hi,

    Excel, like OpenOffice Calc, reads and automatically converts CSV (Comma Separated Values) files.
    The file that REX produced is a special kind of CSV file (with '\t' as separator).

    So, if you need to work on "real" Excel files, you have to use other tools.
    A camel can go 14 days without drink,
    I can't!!!

Similar Threads

  1. Replies: 16
    Last Post: 28th April 2020, 14:40
  2. Replies: 3
    Last Post: 1st February 2011, 11:57
  3. Excel data import
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2010, 11:31
  4. Exporting to RTF
    By gruszczy in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2009, 00:00
  5. Replies: 3
    Last Post: 12th June 2008, 11:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.