Reputation: 101
Is that possible to do some conditional format on Excel file with JXL or Apache POI or something else? API java Like Macro VBA for example?
' 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
Upvotes: 0
Views: 1120
Reputation: 5981
so, in your target language, these are the Excel Objects you need:
Excel.Application
in a variable like oXlAppExcel.Application
object to open your target workbook:
Selection
property of the oxlApp object to return an Excel Range
objectmodify the Selection
or Range
as below:
Execute an Add command on the FormatConditions property of the Range
'
in Excel VBA we would do something like this:
activesheet.usedrange.select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B2<>$C2"
Selection.FormatConditions(1).Interior.ColorIndex = 36
this will first select the used cells, then add a conditional formatting for cols b and c
Also, see this one StackOverFlow: Manipulate Excel from Jacob/Java
and look at the JXL Guide
Upvotes: 1