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