0
Pythonで遊んで、私の色を取り出して一度にいくつかのセルに追加したいのですが、forループを使ってそれについて移動する:forループでPythonの複数のセルを色付けするには
ここでは私のコードは以下のようになります。先制攻撃として
import openpyxl
import xlrd
import xlwt
import time
#Big Header Font Format
font0 = xlwt.Font()
font0.name = 'Times New Roman'
font0.bold = True
font0.height = 400
style0 = xlwt.XFStyle()
style0.font = font0
#Little Header Font Format
font1 = xlwt.Font()
font1.name = 'Times New Roman'
font1.bold = True
font1.height = 240
style1 = xlwt.XFStyle()
style1.font = font1
#Background color format blue
style2 = xlwt.XFStyle()
pattern = xlwt.Pattern()
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = xlwt.Style.colour_map['blue']
style2.pattern = pattern
#Background color format
style3 = xlwt.XFStyle()
pattern = xlwt.Pattern()
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = xlwt.Style.colour_map['light_blue']
style3.pattern = pattern
wb = openpyxl.load_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx')
type(wb)
sheet = wb.get_sheet_by_name('Sheet1')
book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Sheet 1")
sheet1.write(0, 0, "BFI4 AM CARE EOS REPORT", style0, style3)
sheet1.write(0, 6,(time.strftime("%d/%m/%Y")), style0)
sheet1.write(1, 0, 'Encounter Type', style1)
sheet1.write(1, 3, "Day Shift", style1)
sheet1.write(1, 4, "Night Shift", style1)
sheet1.write(1, 5, "Totals", style1)
sheet1.write(1, 6, "WTD", style1)
私は私の sheet1.write
にフォーマットする私のセルに追加した場合、私はエラーを取得します
Traceback (most recent call last):
File "H:/python things/data3.py", line 45, in <module>
sheet1.write(0, 0, "BFI4 AM CARE EOS REPORT", style0, style3)
TypeError: write() takes from 3 to 5 positional arguments but 6 were given
私はこれを回避する方法を知りましたか?同じシェルに別のコード行を追加しようとすると、上書きされません。
大丈夫ああ、私はその後、それらを組み合わせていますか? –