场景
客户要求一眼看清哪些订单要发货了。希望未来七天要发货的每天不同色标识,以免遗漏和方便备货。
一段Python代码搞定,未来七天要发货的黄色背景,字体每天不同色。
其他业务需求可以参考修改源代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # 第一步:按照需要添加程序集引用 import clr clr.AddReference('mscorlib') from System import * def OnFormatRowConditions(args): if (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(1)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#FF0000" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(1)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(2)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#c55a11" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(2)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(3)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#7030a0" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(3)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(4)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#0303fd" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(4)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(5)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#00b0f0" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(5)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(6)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#ec43e4" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(6)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(7)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#002060" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif (args.DataRow.DynamicObject["FDeliveryDate"] >= DateTime.Now.Date.AddDays(7)and args.DataRow.DynamicObject["FDeliveryDate"] < DateTime.Now.Date.AddDays(8)): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#d65db1" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); elif args.DataRow.DynamicObject["FDeliveryDate"] > DateTime.Now.Date.AddDays(8): fc = FormatCondition() fc.ApplayRow = True fc.ForeColor = "#008f7a" fc.BackColor = "#fefedf" args.FormatConditions.Add(fc); |
列表上添加以上Python格式化代码:
暂无评论