diff --git a/examples/xlsx/hello/doc/images/hello.png b/examples/xlsx/hello/doc/images/hello.png new file mode 100644 index 0000000..8c1a862 Binary files /dev/null and b/examples/xlsx/hello/doc/images/hello.png differ diff --git a/examples/xlsx/hello/doc/src/hello.qdoc b/examples/xlsx/hello/doc/src/hello.qdoc index 3377d4c..6549013 100644 --- a/examples/xlsx/hello/doc/src/hello.qdoc +++ b/examples/xlsx/hello/doc/src/hello.qdoc @@ -1,11 +1,20 @@ /*! - \title Qt Xlsx Examples - Hello World \example hello \title Xlsx Hello Example \brief This is a simplest xlsx examples. - \ingroup qtxlsx This example demonstrates how to generate a simplest .xlsx file with Qt Xlsx Library. + \image hello.png + + Create an object of the class QXlsx::Document. + \snippet hello/main.cpp 0 + + Set the cells of worksheet. + \snippet hello/main.cpp 1 + + Save it. + \snippet hello/main.cpp 2 + */ diff --git a/examples/xlsx/hello/hello.pro b/examples/xlsx/hello/hello.pro index ed45049..10d2978 100755 --- a/examples/xlsx/hello/hello.pro +++ b/examples/xlsx/hello/hello.pro @@ -3,4 +3,7 @@ TARGET = hello #include(../../../src/xlsx/qtxlsx.pri) QT+=xlsx +CONFIG += console +CONFIG -= app_bundle + SOURCES += main.cpp diff --git a/examples/xlsx/hello/main.cpp b/examples/xlsx/hello/main.cpp index 3830893..f0a7d78 100755 --- a/examples/xlsx/hello/main.cpp +++ b/examples/xlsx/hello/main.cpp @@ -1,38 +1,23 @@ #include #include "xlsxdocument.h" -#ifdef Q_OS_MAC -# define DATA_PATH "../../../" -#else -# define DATA_PATH "./" -#endif - int main() { + //![0] QXlsx::Document xlsx; + //![0] - //Write to first worksheet. + //![1] xlsx.write("A1", "Hello Qt!"); - xlsx.write("B3", 12345); - xlsx.write("C5", "=44+33"); - xlsx.write("D7", true); - xlsx.write("E1", "http://qt-project.org"); + xlsx.write("A2", 12345); + xlsx.write("A3", "=44+33"); + xlsx.write("A4", true); + xlsx.write("A5", "http://qt-project.org"); + //![1] - //Create another worksheet. - xlsx.addWorksheet(); - //Rows and columns are zero indexed. - //The first cell in a worksheet, "A1", is (0, 0). - xlsx.write(0, 0, "First"); - xlsx.write(1, 0, "Second"); - xlsx.write(2, 0, "Third"); - xlsx.write(3, 0, "Fourth"); - xlsx.write(4, 0, "Total"); - xlsx.write(0, 1, 100); - xlsx.write(1, 1, 200); - xlsx.write(2, 1, 300); - xlsx.write(3, 1, 400); -// xlsx.write(4, 1, "=SUM(B1:B4)"); + //![2] + xlsx.save(); + //![2] - xlsx.saveAs(DATA_PATH"Test.xlsx"); return 0; } diff --git a/examples/xlsx/readwrite/doc/images/readwrite.png b/examples/xlsx/readwrite/doc/images/readwrite.png new file mode 100644 index 0000000..ee3af26 Binary files /dev/null and b/examples/xlsx/readwrite/doc/images/readwrite.png differ diff --git a/examples/xlsx/readwrite/doc/src/readwrite.qdoc b/examples/xlsx/readwrite/doc/src/readwrite.qdoc index 4e8fffa..39da209 100644 --- a/examples/xlsx/readwrite/doc/src/readwrite.qdoc +++ b/examples/xlsx/readwrite/doc/src/readwrite.qdoc @@ -2,9 +2,17 @@ \title Xlsx Readwrite Example \example readwrite \brief Open an existing xlsx file, modify and save it. - \ingroup qtxlsx This example demonstrates how to modify an existing .xlsx file with Qt Xlsx Library. + + \image readwrite.png + + At first, we create an empty xlsx file, set the properties of the document, + write some content to the worksheet, then save it. + \snippet readwrite/main.cpp 0 + + Then we open the exists xlsx file, add some data to it. + \snippet readwrite/main.cpp 1 */ diff --git a/examples/xlsx/readwrite/main.cpp b/examples/xlsx/readwrite/main.cpp index 5c20b73..f30735b 100644 --- a/examples/xlsx/readwrite/main.cpp +++ b/examples/xlsx/readwrite/main.cpp @@ -3,17 +3,25 @@ int main() { //Generate a simple xlsx file at first. + //![0] QXlsx::Document xlsx; + xlsx.setDocumentProperty("title", "This is an example spreadsheet"); + xlsx.setDocumentProperty("creator", "Qt Xlsx Library"); xlsx.setSheetName("First Sheet"); xlsx.write("A1", "Hello Qt!"); xlsx.write("A2", 500); xlsx.saveAs("first.xlsx"); + //![0] //Read, edit, save + //![1] QXlsx::Document xlsx2("first.xlsx"); + xlsx2.write("A3", "Hello Qt again!"); xlsx2.addWorksheet("Second Sheet"); xlsx2.write("A1", "Hello Qt again!"); + xlsx2.setCurrentWorksheet(0); xlsx2.saveAs("second.xlsx"); + //![1] return 0; }