2018-08-14 09:07:09 +09:00
|
|
|
// richtext.cpp
|
|
|
|
|
2019-09-15 20:25:15 +09:00
|
|
|
#include <QtGlobal>
|
2017-09-16 12:21:23 +09:00
|
|
|
#include <QtCore>
|
2019-09-15 20:25:15 +09:00
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
#include "xlsxdocument.h"
|
|
|
|
#include "xlsxrichstring.h"
|
|
|
|
#include "xlsxworkbook.h"
|
|
|
|
#include "xlsxformat.h"
|
|
|
|
|
2017-09-24 00:09:33 +09:00
|
|
|
int richtext()
|
2017-09-16 12:21:23 +09:00
|
|
|
{
|
|
|
|
//![0]
|
|
|
|
QXlsx::Document xlsx;
|
|
|
|
//![0]
|
|
|
|
|
|
|
|
//![1]
|
|
|
|
QXlsx::Format blue;
|
|
|
|
blue.setFontColor(Qt::blue);
|
|
|
|
QXlsx::Format red;
|
|
|
|
red.setFontColor(Qt::red);
|
|
|
|
red.setFontSize(15);
|
|
|
|
QXlsx::Format bold;
|
|
|
|
bold.setFontBold(true);
|
|
|
|
|
|
|
|
QXlsx::RichString rich;
|
|
|
|
rich.addFragment("Hello ", blue);
|
|
|
|
rich.addFragment("Qt ", red);
|
|
|
|
rich.addFragment("Xlsx", bold);
|
|
|
|
xlsx.write("B2", rich);
|
|
|
|
|
|
|
|
xlsx.workbook()->setHtmlToRichStringEnabled(true);
|
|
|
|
xlsx.write("B4", "<b>Hello</b> <font color=\"red\">Qt</font> <i>Xlsx</i>");
|
|
|
|
|
|
|
|
xlsx.write("B6", "<font color=\"red\"><b><u><i>Qt Xlsx</i></u></b></font>");
|
|
|
|
|
|
|
|
//![1]
|
|
|
|
|
|
|
|
//![2]
|
2017-09-24 00:09:33 +09:00
|
|
|
xlsx.saveAs("richtext1.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
//![2]
|
|
|
|
|
2017-09-24 00:09:33 +09:00
|
|
|
QXlsx::Document("richtext1.xlsx");
|
|
|
|
xlsx.saveAs("richtext2.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|