Refactor: Follow Qt5 module's file directories style
Xlsx Shared library can be used now
This commit is contained in:
Executable
+6
@@ -0,0 +1,6 @@
|
||||
TARGET = hello
|
||||
|
||||
#include(../../../src/xlsx/qtxlsx.pri)
|
||||
QT+=xlsx
|
||||
|
||||
SOURCES += main.cpp
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#include <QtCore>
|
||||
#include "xlsxworkbook.h"
|
||||
#include "xlsxworksheet.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
# define DATA_PATH "../../../"
|
||||
#else
|
||||
# define DATA_PATH "./"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
QXlsx::Workbook workbook;
|
||||
QXlsx::Worksheet *sheet = workbook.addWorksheet();
|
||||
sheet->write("A1", "Hello Qt!");
|
||||
sheet->write("B3", 12345);
|
||||
sheet->write("C5", "=44+33");
|
||||
sheet->write("D7", true);
|
||||
|
||||
QXlsx::Worksheet *sheet2 = workbook.addWorksheet();
|
||||
//Rows and columns are zero indexed.
|
||||
//The first cell in a worksheet, "A1", is (0, 0).
|
||||
sheet2->write(0, 0, "First");
|
||||
sheet2->write(1, 0, "Second");
|
||||
sheet2->write(2, 0, "Third");
|
||||
sheet2->write(3, 0, "Fourth");
|
||||
sheet2->write(4, 0, "Total");
|
||||
sheet2->write(0, 1, 100);
|
||||
sheet2->write(1, 1, 200);
|
||||
sheet2->write(2, 1, 300);
|
||||
sheet2->write(3, 1, 400);
|
||||
sheet2->write(4, 1, "=SUM(B1:B4)");
|
||||
|
||||
workbook.save(DATA_PATH"Test.xlsx");
|
||||
workbook.save(DATA_PATH"Test.zip");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#include <QtCore>
|
||||
#include "xlsxworkbook.h"
|
||||
#include "xlsxworksheet.h"
|
||||
#include "xlsxformat.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
# define DATA_PATH "../../../"
|
||||
#else
|
||||
# define DATA_PATH "./"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
QXlsx::Workbook workbook;
|
||||
QXlsx::Worksheet *sheet = workbook.addWorksheet();
|
||||
|
||||
QXlsx::Format *format1 = workbook.addFormat();
|
||||
format1->setFontColor(QColor(Qt::red));
|
||||
format1->setFontSize(15);
|
||||
format1->setHorizontalAlignment(QXlsx::Format::AlignHCenter);
|
||||
format1->setBorderStyle(QXlsx::Format::BorderDashDotDot);
|
||||
sheet->write("A1", "Hello Qt!", format1);
|
||||
sheet->write("B3", 12345, format1);
|
||||
|
||||
QXlsx::Format *format2 = workbook.addFormat();
|
||||
format2->setFontBold(true);
|
||||
format2->setFontUnderline(QXlsx::Format::FontUnderlineDouble);
|
||||
format2->setFillPattern(QXlsx::Format::PatternLightUp);
|
||||
sheet->write("C5", "=44+33", format2);
|
||||
sheet->write("D7", true, format2);
|
||||
|
||||
QXlsx::Format *format3 = workbook.addFormat();
|
||||
format3->setFontBold(true);
|
||||
format3->setFontColor(QColor(Qt::blue));
|
||||
format3->setFontSize(20);
|
||||
sheet->write(10, 0, "Hello Row Style");
|
||||
sheet->write(10, 5, "Blue Color");
|
||||
sheet->setRow(10, 40, format3);
|
||||
|
||||
QXlsx::Format *format4 = workbook.addFormat();
|
||||
format4->setFontBold(true);
|
||||
format4->setFontColor(QColor(Qt::magenta));
|
||||
for (int row=20; row<40; row++)
|
||||
for (int col=8; col<15; col++)
|
||||
sheet->write(row, col, row+col);
|
||||
sheet->setColumn(8, 15, 5.0, format4);
|
||||
|
||||
QXlsx::Format *format5 = workbook.addFormat();
|
||||
format5->setNumberFormat(22);
|
||||
sheet->write("A5", QDate(2013, 8, 29), format5);
|
||||
|
||||
workbook.save(DATA_PATH"TestStyle.xlsx");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
TARGET = style
|
||||
|
||||
#include(../../../src/xlsx/qtxlsx.pri)
|
||||
QT += xlsx
|
||||
|
||||
SOURCES += main.cpp
|
||||
@@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = hello style
|
||||
|
||||
Reference in New Issue
Block a user