Add a new example
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
/*!
|
||||
\example extractdata
|
||||
\title Extract Data Example
|
||||
\brief This is a simplest Qt Xlsx example.
|
||||
\ingroup qtxlsx-examples
|
||||
|
||||
This example demonstrates how to extract data form existing
|
||||
.xlsx file with Qt Xlsx Library. So lets see how this is achieved.
|
||||
|
||||
This creates a new instance of the all important Document
|
||||
class which gives you access to the Excel workbook and worksheets.
|
||||
\snippet hello/main.cpp 0
|
||||
|
||||
Extracts data from current worksheet.
|
||||
\snippet hello/main.cpp 1
|
||||
*/
|
||||
@@ -0,0 +1,9 @@
|
||||
TARGET = extractdata
|
||||
|
||||
#include(../../../src/xlsx/qtxlsx.pri)
|
||||
QT+=xlsx
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <QtCore>
|
||||
#include "xlsxdocument.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
//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.saveAs("Book1.xlsx");
|
||||
}
|
||||
|
||||
//![0]
|
||||
QXlsx::Document xlsx("Book1.xlsx");
|
||||
//![0]
|
||||
|
||||
//![1]
|
||||
qDebug()<<xlsx.read("A1");
|
||||
qDebug()<<xlsx.read("A2");
|
||||
qDebug()<<xlsx.read("A3");
|
||||
qDebug()<<xlsx.read("A4");
|
||||
qDebug()<<xlsx.read("A5");
|
||||
//![1]
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user