新手!请保持温柔。 我正在尝试使用带有某种格式的openpyxl保存工作表。
我的工作表中有空白/空单元格,我想对其进行格式化/填充。
所以。查找所有空白/空单元格 应用PatternFill
import openpyxl
from openpyxl import Workbook
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
from openpyxl.styles import Fill, Color
catalogwb = openpyxl.load_workbook(currentDir + fileName)
catalogws = catalogwb.active
catalogws1 = catalogwb.create_sheet("Sheet2")
testcell = catalogws['B2']
testcell.fill = PatternFill("solid", fgColor="DDDDDD") #works!
max_row=catalogws.max_row
max_col=catalogws.max_column
print(max_row , max_col)
catalogws.column_dimensions['B'].width = 80
myFill = PatternFill("solid", fgColor="DDDDDD")
catalogws.cell(row=max_row,column=max_col).fill = myFill #works!
为此花费了太多时间。 谢谢!