You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mysql database data size is 40909 rows and 50 colums, when use the code to export these data as blew the computer memery will be reached to 800Mb. the real excel file size only 7Mb. could anyone told me how to decrease the memery usage?
`
QXlsx::Document xlsx;
QXlsx::Format format;
QModelIndex indexItem;
QVariant data ;
if(exportFileName.isEmpty())
return;
QFile file(exportFileName);;
if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
MsgBox *msgBox = new MsgBox(Msg_Warning,exportFileName + "\n" + tr("The file is opend,please close file!"));
msgBox->exec();
delete msgBox;
return;
}
else
{
int rowCount = modelCrm->rowCount();
int colCount = modelCrm->columnCount();
ui->progressBar->setMaximum(rowCount);
for (int i = 0; i < rowCount;i++)
{
QCoreApplication::processEvents();
for(int j = 0; j < colCount; j++)
{
indexItem = modelCrm->index(i,j,QModelIndex());//rowNum,columnNum为行列号
data = indexItem.data();
xlsx.write(i+3,j+1, data.toString());
}
}
}
QFuture<void> future = QtConcurrent::run([&]() {
qDebug() << __FUNCTION__ << QThread::currentThreadId() << QThread::currentThread();
xlsx.saveAs(exportFileName);
});
ui->progressBar->setRange(0, 0);
// Set the progress bar to an indeterminate state
while (!future.isFinished()) {
QApplication::processEvents(QEventLoop::AllEvents, 10);
} `
The text was updated successfully, but these errors were encountered:
The mysql database data size is 40909 rows and 50 colums, when use the code to export these data as blew the computer memery will be reached to 800Mb. the real excel file size only 7Mb. could anyone told me how to decrease the memery usage?
`
QXlsx::Document xlsx;
QXlsx::Format format;
QModelIndex indexItem;
QVariant data ;
The text was updated successfully, but these errors were encountered: