forked from totravel/minidocx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.cpp
37 lines (27 loc) · 1.03 KB
/
table.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "minidocx.hpp"
#include <iostream>
using namespace docx;
int main()
{
Document doc;
auto tbl = doc.AppendTable(4, 5);
tbl.GetCell(0, 0).FirstParagraph().AppendRun("AAA");
tbl.GetCell(0, 1).FirstParagraph().AppendRun("BBB");
tbl.GetCell(0, 2).FirstParagraph().AppendRun("CCC");
tbl.GetCell(0, 3).FirstParagraph().AppendRun("DDD");
tbl.GetCell(1, 0).FirstParagraph().AppendRun("EEE");
tbl.GetCell(1, 1).FirstParagraph().AppendRun("FFF");
tbl.SetAlignment(Table::Alignment::Centered);
tbl.SetTopBorders(Table::BorderStyle::Single, 1, "FF0000");
tbl.SetBottomBorders(Table::BorderStyle::Dotted, 2, "00FF00");
tbl.SetLeftBorders(Table::BorderStyle::Dashed, 3, "0000FF");
tbl.SetRightBorders(Table::BorderStyle::DotDash, 1, "FFFF00");
tbl.SetInsideHBorders(Table::BorderStyle::Double, 1, "FF00FF");
tbl.SetInsideVBorders(Table::BorderStyle::Wave, 1, "00FFFF");
tbl.SetCellMarginLeft(CM2Twip(0.19));
tbl.SetCellMarginRight(CM2Twip(0.19));
// std::cout << doc;
doc.Save("table.docx");
return 0;
}