Repository navigation
Expand file tree
/
Copy pathtextbox.py
More file actions
177 lines (153 loc) · 3.7 KB
/
Copy pathtextbox.py
File metadata and controls
177 lines (153 loc) · 3.7 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#######################################################################
#
# An example of inserting textboxes into an Excel worksheet using
# Python and XlsxWriter.
#
# Copyright 2013-2015, John McNamara, jmcnamara@cpan.org
#
import xlsxwriter
workbook = xlsxwriter.Workbook('textbox.xlsx')
worksheet = workbook.add_worksheet()
row = 4
col = 1
# The examples below show different textbox options and formatting. In each
# example the text describes the formatting.
# Example
text = 'A simple textbox with some text'
worksheet.insert_textbox(row, col, text)
row += 10
# Example
text = 'A textbox with changed dimensions'
options = {
'width': 256,
'height': 100,
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with an offset in the cell'
options = {
'x_offset': 10,
'y_offset': 10,
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with scaling'
options = {
'x_scale': 1.5,
'y_scale': 0.8,
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with some long text that wraps around onto several lines'
worksheet.insert_textbox(row, col, text)
row += 10
# Example
text = 'A textbox\nwith some\nnewlines\n\nand paragraphs'
worksheet.insert_textbox(row, col, text)
row += 10
# Example
text = 'A textbox with a solid fill background'
options = {
'fill': {'color': 'red'},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with a no fill background'
options = {
'fill': {'none': True},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with a gradient fill background'
options = {
'gradient': {'colors': ['#DDEBCF',
'#9CB86E',
'#156B13']},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with a user defined border line'
options = {
'border': {'color': 'red',
'width': 3,
'dash_type': 'round_dot'},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'A textbox with no border line'
options = {
'border': {'none': True},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'Default alignment: top - left'
worksheet.insert_textbox(row, col, text)
row += 10
# Example
text = 'Alignment: top - center'
options = {
'align': {'horizontal': 'center'},
}
worksheet.insert_textbox(row, col, text)
row += 10
# Example
text = 'Alignment: top - center'
options = {
'align': {'horizontal': 'center'},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'Alignment: middle - center'
options = {
'align': {'vertical': 'middle',
'horizontal': 'center'},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'Font properties: bold'
options = {
'font': {'bold': True},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'Font properties: various'
options = {
'font': {'bold': True},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'Font properties: various'
options = {
'font': {'bold': True,
'italic': True,
'underline': True,
'name': 'Arial',
'color': 'red',
'size': 12}
}
worksheet.insert_textbox(row, col, text, options)
row += 10
# Example
text = 'Some text in a textbox with formatting'
options = {
'font': {'color': 'white'},
'align': {'vertical': 'middle',
'horizontal': 'center'
},
'gradient': {'colors': ['red', 'blue']},
}
worksheet.insert_textbox(row, col, text, options)
row += 10
workbook.close()