Python中的Excel VBA FormatConditions

2024-09-30 16:35:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将以下代码转换为python:

            Columns("C:C").Select
            Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
                , Formula1:="=50"
            Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
            With Selection.FormatConditions(1).Interior
                .PatternColorIndex = xlAutomatic
                .Color = 5296274
                .TintAndShade = 0
            End With
            Selection.FormatConditions(1).StopIfTrue = True

我有下面的python代码:

^{pr2}$

我得到了以下错误:

'<win32com.gen_py.Microsoft Excel 12.0 Object Library._Application instance at 0x174381576>' object has no attribute 'XlFormatConditionType'

Tags: columns代码addtypecountwithselectoperator