有一些特定行为的高级属性,最常用的是页面设置参数(page setup property) fitTopage 和 定义工作表选项卡颜色的`tabColor`。
- "enableFormatConditionsCalculation"
- "filterMode"
- "published"
- "syncHorizontal"
- "syncRef"
- "syncVertical"
- "transitionEvaluation"
- "transitionEntry"
- "tabColor"
"autoPageBreaks" "fitToPage"
- "applyStyles"
- "summaryBelow"
- "summaryRight"
- "showOutlineSymbols"
Note
默认情况下,会对 outline 属性进行初始化,因此您可以直接修改它们的 4 个属性,而页面设置属性不一样。 如果要修改后者,首先要必要的参数初始化对 openpyxl.worksheet.properties.PageSetupProperties 对象进行初始化。 一旦完成,可以在以后需要时通过例程直接对其进行修改。
>>> from openpyxl.workbook import Workbook
>>> from openpyxl.worksheet.properties import WorksheetProperties, PageSetupProperties
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> wsprops = ws.sheet_properties
>>> wsprops.tabColor = "1072BA"
>>> wsprops.filterMode = False
>>> wsprops.pageSetUpPr = PageSetupProperties(fitToPage=True, autoPageBreaks=False)
>>> wsprops.outlinePr.summaryBelow = False
>>> wsprops.outlinePr.applyStyles = True
>>> wsprops.pageSetUpPr.autoPageBreaks = True