Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with saving big Excel files #291

Open
vladd12 opened this issue Jun 22, 2023 · 1 comment
Open

Bug with saving big Excel files #291

vladd12 opened this issue Jun 22, 2023 · 1 comment

Comments

@vladd12
Copy link

vladd12 commented Jun 22, 2023

I have a similar code:

auto doc = new QXlsx::Document(filename, this);
auto workSheet = doc->currentWorksheet();
// ... some code for getting dataModel
auto modelSize = dataModel->itemCount();
for (int i = 0; i < modelSize; ++i)
{
    for (int j = 2; j < dataModel->columnCount(); ++j)
    {
        currentCell.setColumn(1 + j);
        QVariant value = dataModel->data(dataModel->index(i, j), Qt::DisplayRole);
        switch (value.type())
        {
        case QVariant::Type::Double:
            workSheet->writeNumeric(currentCell, value.toFloat());
            break;
        case QVariant::Type::Int:
            workSheet->writeNumeric(currentCell, value.toInt());
            break;
        default:
            workSheet->writeString(currentCell, value.toString());
            break;
        }
    }
    QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
doc->save();
doc->deleteLater();

The dataModel is instance of class, that's inherits the QAbstractTableModel class. It can contain a large amount of data. In my case I trying to write in .xlsx file 30k rows with 6 columns for each row. During the execution of the doc destructor, the main application freezes. Using CDB I saw that the application executes destructors of a large number of QSharedPointer objects. But the application freezes for a very long time, it feels like there is some kind of memory corruption somewhere inside QXlsx. If someone has encountered a similar problem please help me with its solution, I will be very grateful! 😅

@j2doll
Copy link
Member

j2doll commented Dec 18, 2023

Dear @vladd12

Can you pull request your example in the repository?

https://github.com/JayTwoLab/QXlsx-291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants