/
10_format_for_row.py
47 lines (37 loc) · 1.25 KB
/
10_format_for_row.py
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
#!/usr/bin/env python3
# vim: set fileencoding=utf-8
#
# (C) Copyright 2021 Pavel Tisnovsky
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Pavel Tisnovsky
#
"""Vytvoření sešitu s delší tabulkou, nastavení stylu řádků."""
import xlsxwriter
# vytvoření objektu reprezentujícího celý sešit
with xlsxwriter.Workbook("example10.xlsx") as workbook:
# vložení nového listu do sešitu
worksheet = workbook.add_worksheet()
# nastavení šířky sloupců
worksheet.set_column("A:A", 8)
worksheet.set_column("B:B", 14)
worksheet.set_column("C:Z", 2)
# definice nového stylu
bold_style = workbook.add_format()
bold_style.set_bold()
bold_style.set_font_color("blue")
# styl pro první řádek
worksheet.set_row(0, 20, bold_style)
# buňky s textem
worksheet.write("A1", "x")
worksheet.write("B1", "1/x")
# buňky s numerickými hodnotami
for x in range(1, 21):
worksheet.write(x, 0, x)
worksheet.write(x, 1, 1.0 / x)
# sešit bude uzavřen automaticky