56 lines
1.0 KiB
Python
56 lines
1.0 KiB
Python
from sumaexcel import SumasenExcel
|
|
|
|
# 初期化
|
|
excel = SumasenExcel()
|
|
excel.init("username", "project_id", "document")
|
|
|
|
# シート初期化
|
|
excel.init_sheet("Sheet1")
|
|
|
|
# スタイル適用
|
|
excel.apply_style(
|
|
"A1:D10",
|
|
font={"name": "Arial", "size": 12, "bold": True},
|
|
fill={"start_color": "FFFF00"},
|
|
alignment={"horizontal": "center"}
|
|
)
|
|
|
|
# セルのマージ
|
|
excel.merge_range(1, 1, 1, 4)
|
|
|
|
# 画像追加
|
|
excel.add_image(
|
|
"logo.png",
|
|
position=(1, 1),
|
|
size=(100, 100)
|
|
)
|
|
|
|
# 条件付き書式
|
|
excel.add_conditional_format(
|
|
"B2:B10",
|
|
format_type="color_scale",
|
|
min_color="00FF0000",
|
|
max_color="0000FF00"
|
|
)
|
|
|
|
# ページ設定
|
|
excel.setup_page(
|
|
orientation="landscape",
|
|
paper_size=PaperSizes.A4,
|
|
margins={
|
|
"left": 1.0,
|
|
"right": 1.0,
|
|
"top": 1.0,
|
|
"bottom": 1.0
|
|
},
|
|
header_footer={
|
|
"odd_header": "&L&BPage &P of &N&C&BConfidential",
|
|
"odd_footer": "&RDraft"
|
|
}
|
|
)
|
|
|
|
# レポート生成
|
|
excel.make_report(db, data_rec)
|
|
|
|
|