"Large" 使用 C++ Qt 和 Qt xlsx 模块读取 xlsx 文件
"Large" xlsx file reading using C++ Qt and Qt Xlsx Module
我正在使用Qt框架在C++中开发一个应用程序,但我需要读取.xslx文件才能将其导入sqlite数据库。我正在使用Qt-Xlsx模块,但我发现一些困难,因为我的程序在执行过程中的某个随机点崩溃。该文件大约有1500行和10列。我能读700到1000行,但后来它崩溃了。我认为这是内存问题,但我无法使用Valgrind,因为我在Mac OS X系统上。我的代码的相关部分如下。
void Controller::ImportDatabase(const QString &filepath)
{
QStringList* person_fields = new QStringList;
QXlsx::Document *xlsx_database = new QXlsx::Document(filepath);
int number_of_row = xlsx_database->dimension().lastRow();
int number_of_column = xlsx_database->dimension().lastColumn();
for (int row = 2; row <= number_of_row; ++row) {
++count;
qDebug() << "count: " << count;
for(int column = 0; column < number_of_column ; ++column) {
if ((QXlsx::Cell *cell = xlsx_database->cellAt(row, column))) {
person_fields->append(cell->value().toString());
delete cell;
}
}
qDebug() << "NOME: " << person_fields->at(0);
//Create a new Person and pass its pointer around: all commented anyway
person_fields->clear();
delete cell;
}
delete person_fields;
delete xlsx_database;
}
任何建议或想法都将不胜感激。
您必须NOT删除cell
,因为它归QXlsx::Document所有。
相关文章:
- Qt VTK交互风格的信号到小部件
- QT在错误的班级中寻找空位
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 如何在Qt C++中更改光标
- 如何在MS Visual Studio 2019中运行QT UI
- QT通过C++添加映射QML项目
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用Qt C++计算类似Git的SHA1哈希
- Qt focusObjectChanged example?
- 如何在cpp文件之间切换窗口?在Qt中
- Qt和C++:将QLineEdit添加到QTabWidget中
- 从数据库实时显示QT c++中的数据
- Qt Quick-如何仅从c++代码与qml属性交互
- 无法使用Qt Creator在Windows中构建yaml-cpp
- 如何在Qt中打印.xlsx格式
- Qt使用ODBC驱动程序连接到XLSX文件
- "Large" 使用 C++ Qt 和 Qt xlsx 模块读取 xlsx 文件