Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use the ConditionFormatOperator CONTAINS?

I'm trying to write a spreadsheet macro that conditionally formats rows of a range I've named. LibreOffice allows an operator of Contains to be used and I am trying to write a macro that automates this. The following code does NOT work. What am I missing?

sub formatTeamTable
breaks = ThisComponent.sheets.getByName("Tiebreakers")
table = breaks.getCellRangeByName("TeamTable")
tableColumns = table.Rows.Count-1
dim condition(2) as new com.sun.star.beans.PropertyValue
for r = 0 to tableColumns
    condition(0).Name = "Operator"
    condition(0).Value = com.sun.star.sheet.ConditionFormatOperator.CONTAINS
    condition(1).Name = "Formula1"
    condition(1).Value = """Tied"""
    condition(2).Name = "StyleName"
    condition(2).Value = "Tied"
    row = table.getCellRangeByPosition(0,r,tableColumns,r)
    cf = row.ConditionalFormat : cf.addNew(condition) : row.ConditionalFormat = cf
next

end sub

How to use the ConditionFormatOperator CONTAINS?

I'm trying to write a spreadsheet macro that conditionally formats rows of a range I've named. LibreOffice allows an operator of Contains to be used and I am trying to write a macro that automates this. The following code does NOT work. What am I missing?

sub formatTeamTable
breaks = ThisComponent.sheets.getByName("Tiebreakers")
table = breaks.getCellRangeByName("TeamTable")
tableColumns = table.Rows.Count-1
dim condition(2) as new com.sun.star.beans.PropertyValue
for r = 0 to tableColumns
    condition(0).Name = "Operator"
    condition(0).Value = com.sun.star.sheet.ConditionFormatOperator.CONTAINS
    condition(1).Name = "Formula1"
    condition(1).Value = """Tied"""
    condition(2).Name = "StyleName"
    condition(2).Value = "Tied"
    row = table.getCellRangeByPosition(0,r,tableColumns,r)
    cf = row.ConditionalFormat : cf.addNew(condition) : row.ConditionalFormat = cf
next

end sub