添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
def set_formatconditions_bar(self, i, j):
     # 获取区域范围 rng_dl = self.yx_sheet1.range((2,j),(i,j)) rng_dl.api.FormatConditions.Delete() # 添加数据条 rng_dl.api.FormatConditions.AddDatabar() rng_dl.api.FormatConditions(rng_dl.api.FormatConditions.Count).SetFirstPriority() rng_dl.api.FormatConditions(1).MinPoint.Modify.newtype = xw.constants.ConditionValueTypes.xlConditionValueAutomaticMin rng_dl.api.FormatConditions(1).MaxPoint.Modify.newtype = xw.constants.ConditionValueTypes.xlConditionValueAutomaticMax # 数据条颜色 rng_dl.api.FormatConditions(1).BarColor.Color = rgb_to_int([255,222,125]) rng_dl.api.FormatConditions(1).BarColor.TintAndShade = 0 # 数据条颜色方向等设置 rng_dl.api.FormatConditions(1).BarFillType = xw.constants.DataBarFillType.xlDataBarFillSolid rng_dl.api.FormatConditions(1).Direction = xw.constants.Constants.xlContext rng_dl.api.FormatConditions(1).NegativeBarFormat.ColorType = xw.constants.DataBarNegativeColorType.xlDataBarColor rng_dl.api.FormatConditions(1).BarBorder.Type = xw.constants.DataBarBorderType.xlDataBarBorderNone rng_dl.api.FormatConditions(1).AxisPosition = xw.constants.DataBarAxisPosition.xlDataBarAxisAutomatic      # axis颜色 设置 rng_dl.api.FormatConditions(1).AxisColor.Color = rgb_to_int([255,255,255]) rng_dl.api.FormatConditions(1).AxisColor.TintAndShade = 0

示例2:添加 三色刻度

def set_formatconditions_colorscale(self,i,j):
        # 选择区域
        rng = sheet1.range((i+1,3),(i+1,j-4))
        # 删除原来的 条件格式
        rng.api.FormatConditions.Delete
        # 添加色彩刻度, 2为双色, 3为三色
        rng.api.FormatConditions.AddColorScale(ColorScaleType=3)
        rng.api.FormatConditions(rng.api.FormatConditions.Count).SetFirstPriority()
        # 最小值颜色设置
        rng.api.FormatConditions(1).ColorScaleCriteria(1).Type = xw.constants.ConditionValueTypes.xlConditionValueLowestValue
        rng.api.FormatConditions(1).ColorScaleCriteria(1).FormatColor.Color = rgb_to_int([107,177,137])
        # 中间值颜色设置
        rng.api.FormatConditions(1).ColorScaleCriteria(2).Type = xw.constants.ConditionValueTypes.xlConditionValuePercentile
        rng.api.FormatConditions(1).ColorScaleCriteria(2).FormatColor.Color = rgb_to_int([255,232,115]) # [255,255,255][255,216,64]
        # 最大值颜色设置
        rng.api.FormatConditions(1).ColorScaleCriteria(3).Type = xw.constants.ConditionValueTypes.xlConditionValueHighestValue
        rng.api.FormatConditions(1).ColorScaleCriteria(3).FormatColor.Color = rgb_to_int([250,128,114])