From 02710b254460e0299d59bc5a7b5f55dc4c747f02 Mon Sep 17 00:00:00 2001 From: Jay Two Date: Fri, 28 Dec 2018 21:10:21 +0900 Subject: [PATCH] append debugging information for HelloWorld example --- HelloWorld/main.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/HelloWorld/main.cpp b/HelloWorld/main.cpp index 0070b0a..ee7b41c 100644 --- a/HelloWorld/main.cpp +++ b/HelloWorld/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -36,20 +37,40 @@ int main(int argc, char *argv[]) // [1] Writing excel file(*.xlsx) QXlsx::Document xlsxW; xlsxW.write("A1", "Hello Qt!"); // write "Hello Qt!" to cell(A,1). it's shared string. - xlsxW.saveAs("Test.xlsx"); // save the document as 'Test.xlsx' + if (xlsxW.saveAs("Test.xlsx")) // save the document as 'Test.xlsx' + { + qDebug() << "[debug] success to write xlsx file"; + } + else + { + qDebug() << "[debug][error] failed to write xlsx file"; + } + + qDebug() << "[debug] current directory is " << QDir::currentPath(); // [2] Reading excel file(*.xlsx) Document xlsxR("Test.xlsx"); // load excel file if (xlsxR.isLoadPackage()) { + qDebug() << "[debug] success to load xlsx file."; + int row = 1; int col = 1; Cell* cell = xlsxR.cellAt(row, col); // get cell pointer. if ( cell != NULL ) { QVariant var = cell->readValue(); // read cell value (number(double), QDateTime, QString ...) + qDebug() << var; // display value } + else + { + qDebug() << "[debug][error] cell(1,1) is not set."; + } } + else + { + qDebug() << "[debug][error] failed to load xlsx file."; + } return 0; }