2017-09-16 16:34:45 +09:00
|
|
|
// extractdata.cpp
|
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
#include "xlsxdocument.h"
|
|
|
|
|
2023-09-04 00:46:33 -03:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QtCore>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2017-09-16 16:34:45 +09:00
|
|
|
int extractdata()
|
2017-09-16 12:21:23 +09:00
|
|
|
{
|
|
|
|
{
|
2023-09-04 00:46:33 -03:00
|
|
|
// Create a new .xlsx file.
|
|
|
|
QXlsx::Document xlsx;
|
|
|
|
xlsx.write("A1", "Hello Qt!");
|
|
|
|
xlsx.write("A2", 12345);
|
|
|
|
xlsx.write("A3", "=44+33");
|
|
|
|
xlsx.write("A4", true);
|
|
|
|
xlsx.write("A5", "http://qt-project.org");
|
|
|
|
xlsx.write("A6", QDate(2013, 12, 27));
|
|
|
|
xlsx.write("A7", QTime(6, 30));
|
|
|
|
xlsx.saveAs("extractdata.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
//![0]
|
2017-09-23 11:12:59 +09:00
|
|
|
QXlsx::Document xlsx("extractdata.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
//![0]
|
|
|
|
|
|
|
|
//![1]
|
2023-09-04 00:46:33 -03:00
|
|
|
qDebug() << "extractdata.xlsx - QXlsx::Document.read()";
|
|
|
|
qDebug() << xlsx.read("A1");
|
|
|
|
qDebug() << xlsx.read("A2");
|
|
|
|
qDebug() << xlsx.read("A3");
|
|
|
|
qDebug() << xlsx.read("A4");
|
|
|
|
qDebug() << xlsx.read("A5");
|
|
|
|
qDebug() << xlsx.read("A6");
|
|
|
|
qDebug() << xlsx.read("A7");
|
2017-09-16 12:21:23 +09:00
|
|
|
//![1]
|
|
|
|
|
|
|
|
//![2]
|
2023-09-04 00:46:33 -03:00
|
|
|
qDebug() << "extractdata.xlsx - QXlsx::Cell.value()";
|
|
|
|
for (int row = 1; row < 10; ++row) {
|
2024-09-02 17:11:10 -03:00
|
|
|
if (auto cell = xlsx.cellAt(row, 1)) {
|
2023-09-04 00:46:33 -03:00
|
|
|
qDebug() << cell->value();
|
|
|
|
}
|
2017-09-16 12:21:23 +09:00
|
|
|
}
|
|
|
|
//![2]
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|