2017-09-16 16:34:45 +09:00
|
|
|
// mergecells.cpp
|
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
#include "xlsxdocument.h"
|
|
|
|
#include "xlsxformat.h"
|
|
|
|
|
2023-09-04 00:46:33 -03:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2020-06-05 22:20:08 +09:00
|
|
|
QXLSX_USE_NAMESPACE
|
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
|
|
|
|
2019-09-11 22:09:43 +09:00
|
|
|
//![2]
|
|
|
|
|
|
|
|
// mergedCells
|
|
|
|
|
|
|
|
//![2]
|
|
|
|
|
2023-09-04 00:46:33 -03:00
|
|
|
xlsx.saveAs("mergecells.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|