[英]VSTO vb.net excel with conditional formatting
我是 vb.net 和 VSTO 的新手,文檔不適用於條件格式,因為我正在將代碼從 VBA 修改為 vb.net 有什么想法嗎?
With customerYearRng
.FormatConditions.AddIconSetCondition()
'.IconSetCondition.IconSet.IconSets = "xl3Triangles"
'.FormatConditions(FormatConditions.Count).SetFirstPriority
'.FormatConditions(1)
'.FormatConditions.ReverseOrder = False
'.FormatConditions.ShowIconOnly = False
'.FormatConditions.IconSet.IconSets = "xl3Triangles"
'.FormatConditions(1).IconCriteria(2)
'.Type = xlConditionValueNumber
'.Value = 0
'.Operator = 7
'.FormatConditions(1).IconCriteria(3)
'.Type = xlConditionValueNumber
'.Value = 0
'.Operator = 5
End With
I'm not a VB.NET or VSTO programmer, but the small amount of Excel automation I've done from .NET seemed a pretty straightforward translation from a working VBA implementation.
如果您利用AddIconSetCondition
返回添加的條件這一事實,您的代碼可以更容易處理,因此您不必 go 在范圍的FormatConditions
集合中查找它。
工作 VBA (我認為這與您想要在 VB.NET 中設置的內容接近)-
Sub Tester()
Dim rng As Range, isc As IconSetCondition
Set rng = Selection 'or whatever
Set isc = rng.FormatConditions.AddIconSetCondition()
isc.SetFirstPriority
isc.IconSet = rng.Parent.Parent.IconSets(xl3Triangles)
isc.ReverseOrder = False
isc.ShowIconOnly = False
With isc.IconCriteria(2)
.Type = xlConditionValueNumber
.Value = 0
.Operator = 7
End With
With isc.IconCriteria(3)
.Type = xlConditionValueNumber
.Value = 0
.Operator = 5
End With
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.