可以使用JXL或Apache POI或其他东西在Excel文件上执行某些条件格式吗? API java比如宏VBA吗?
' Mise en forme couleur pour différence
For i = 3 To fin Step 1
Range("C" & i).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=B" & i
Selection.FormatConditions(1).Interior.ColorIndex = 6
答案 0 :(得分:1)
因此,在您的目标语言中,这些是您需要的Excel对象:
Excel.Application
的实例
Excel.Application
对象打开目标工作簿:
Selection
属性返回Excel Range
对象修改Selection
或Range
,如下所示:
在范围
的 FormatConditions 属性上执行添加命令
在 Excel VBA 中,我们会这样做:
activesheet.usedrange.select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B2<>$C2"
Selection.FormatConditions(1).Interior.ColorIndex = 36
这将首先选择使用过的单元格,然后为cols b和c
添加条件格式另外,请看这个 StackOverFlow: Manipulate Excel from Jacob/Java
并查看JXL Guide