(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
link to source: https://github.com/tisnik/most-popular-python-libs/blob/master/PySimpleGUI/20_html_background_colors.py
link to source in literate programming format: https://tisnik.github.io/most-popular-python-libs/PySimpleGUI/20_html_background_colors.html Vytvoření sešitu s delší tabulkou, nastavení barvy pozadí.
import xlsxwriter
vytvoření objektu reprezentujícího celý sešit
with xlsxwriter.Workbook("example20.xlsx") as workbook:
vložení nového listu do sešitu
worksheet = workbook.add_worksheet()
nastavení šířky sloupců
worksheet.set_column("A:A", 20)
barvy buněk
colors = (
"#000000",
"#0000ff",
"#800000",
"#00ffff",
"#808080",
"#008000",
"#00ff00",
"#ff00ff",
"#000080",
"#ff6600",
"#ff00ff",
"#800080",
"#ff0000",
"#c0c0c0",
"#ffffff",
"#ffff00",
)
buňky s řetězci a různou barvou pozadí buněk
for x, color in enumerate(colors):
style = workbook.add_format()
style.set_bg_color(color)
worksheet.write_string(x, 0, color, style)
sešit bude uzavřen automaticky