rex
20th February 2011, 08:15
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
if(newfiles==0)
{
newfilename = "E:/"+ QDateTime::currentDateTime().toString("ddd dd-MM-yyyy, hh.mm") +".xls";
newfiles++;
}
file4 = new QFile(newfilename);
file4->open(QFile::ReadWrite | QFile::Text);
QSqlQuery sq1("SELECT "+ colames +" FROM thdata where rowid = " + QString::number(rowcnt1));
while(sq1.next())
{
for (int i = 0; i < colames.size(); i++)
{
tpdata.push_back(sq1.value(i).toString());
}
}
QTextStream out4(file4);
for(int d = 0;d < tempchnames.count();d++) //Selected Channel Names
{
out4 << tempchnames.at(d);
out4 <<'\t'<<'\t' ;
}
out4 << "Time";
out4 <<'\t'<<'\t' ;
out4 <<"\n" <<"";
for(int j=0; j< tpdata.count(); j++) // Selected Channel Data
{
out4 << tpdata.at(j);
out4 <<'\t'<<'\t' ;
}
}
QTextStream out1(file4);
while(!out1.atEnd())
{
QStringList list2;
QString line2 = out1.readLine();
list2 = line2.split("\n");
}
}
dont know what i am doing wrong the data is not been updated after the first row. ??
thank you
if(newfiles==0)
{
newfilename = "E:/"+ QDateTime::currentDateTime().toString("ddd dd-MM-yyyy, hh.mm") +".xls";
newfiles++;
}
file4 = new QFile(newfilename);
file4->open(QFile::ReadWrite | QFile::Text);
QSqlQuery sq1("SELECT "+ colames +" FROM thdata where rowid = " + QString::number(rowcnt1));
while(sq1.next())
{
for (int i = 0; i < colames.size(); i++)
{
tpdata.push_back(sq1.value(i).toString());
}
}
QTextStream out4(file4);
for(int d = 0;d < tempchnames.count();d++) //Selected Channel Names
{
out4 << tempchnames.at(d);
out4 <<'\t'<<'\t' ;
}
out4 << "Time";
out4 <<'\t'<<'\t' ;
out4 <<"\n" <<"";
for(int j=0; j< tpdata.count(); j++) // Selected Channel Data
{
out4 << tpdata.at(j);
out4 <<'\t'<<'\t' ;
}
}
QTextStream out1(file4);
while(!out1.atEnd())
{
QStringList list2;
QString line2 = out1.readLine();
list2 = line2.split("\n");
}
}
dont know what i am doing wrong the data is not been updated after the first row. ??
thank you