2017-09-16 16:34:45 +09:00
|
|
|
// mergecells.cpp
|
|
|
|
|
2018-08-14 09:07:09 +09:00
|
|
|
// QXlsx
|
|
|
|
// MIT License
|
|
|
|
// https://github.com/j2doll/QXlsx
|
|
|
|
//
|
|
|
|
// QtXlsx
|
|
|
|
// https://github.com/dbzhang800/QtXlsxWriter
|
|
|
|
// http://qtxlsx.debao.me/
|
|
|
|
// MIT License
|
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
#include "xlsxdocument.h"
|
|
|
|
#include "xlsxformat.h"
|
|
|
|
|
2017-10-05 14:59:46 +09:00
|
|
|
using namespace QXlsx;
|
2017-09-16 12:21:23 +09:00
|
|
|
|
2017-09-16 16:34:45 +09:00
|
|
|
int mergecells()
|
2017-09-16 12:21:23 +09:00
|
|
|
{
|
|
|
|
Document xlsx;
|
2017-09-23 11:12:59 +09:00
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
//![0]
|
|
|
|
Format format;
|
|
|
|
format.setHorizontalAlignment(Format::AlignHCenter);
|
|
|
|
format.setVerticalAlignment(Format::AlignVCenter);
|
|
|
|
//![0]
|
2017-09-23 11:12:59 +09:00
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
//![1]
|
|
|
|
xlsx.write("B4", "Hello Qt!");
|
|
|
|
xlsx.mergeCells("B4:F6", format);
|
|
|
|
xlsx.write("B8", 1);
|
|
|
|
xlsx.mergeCells("B8:C21", format);
|
|
|
|
xlsx.write("E8", 2);
|
|
|
|
xlsx.mergeCells("E8:F21", format);
|
|
|
|
//![1]
|
2017-09-23 11:12:59 +09:00
|
|
|
|
|
|
|
xlsx.saveAs("mergecells.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|