Debao Zhang
11 years ago
5 changed files with 0 additions and 65 deletions
Before Width: | Height: | Size: 35 KiB |
@ -1,18 +0,0 @@ |
|||||
/*! |
|
||||
\title Xlsx Readwrite Example |
|
||||
\example readwrite |
|
||||
\brief Open an existing xlsx file, modify and save it. |
|
||||
\ingroup qtxlsx-examples |
|
||||
|
|
||||
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 |
|
||||
*/ |
|
@ -1,34 +0,0 @@ |
|||||
#include "xlsxdocument.h" |
|
||||
#include "xlsxformat.h" |
|
||||
|
|
||||
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"); |
|
||||
QXlsx::Format *format = xlsx.createFormat(); |
|
||||
format->setFontColor(QColor(Qt::blue)); |
|
||||
format->setFontSize(15); |
|
||||
format->setBorderStyle(QXlsx::Format::BorderDashDotDot); |
|
||||
format->setPatternBackgroundColor(QColor(Qt::gray)); |
|
||||
format->setHorizontalAlignment(QXlsx::Format::AlignHCenter); |
|
||||
xlsx.write("A1", "Hello Qt!", format); |
|
||||
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; |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
TARGET = mergecells |
|
||||
|
|
||||
#include(../../../src/xlsx/qtxlsx.pri) |
|
||||
QT += xlsx |
|
||||
|
|
||||
TARGET = readwrite |
|
||||
CONFIG += console |
|
||||
CONFIG -= app_bundle |
|
||||
|
|
||||
TEMPLATE = app |
|
||||
|
|
||||
SOURCES += main.cpp |
|
Loading…
Reference in new issue