Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Conditional formatting is described at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Conditional_Formats. The operator must be of type com.sun.star.sheet.ConditionOperator, not com.sun.star.sheet.ConditionFormatOperator like in your attempt.

Here is working code using EQUAL.

sub formatTeamTable
    breaks = ThisComponent.sheets.getByName("Tiebreakers")
    table = breaks.getCellRangeByName("TeamTable")
    cf = table.getPropertyValue("ConditionalFormat")
    cf.Clear()
    dim condition(3) as new com.sun.star.beans.PropertyValue
    condition(0).Name = "Operator"
    condition(0).Value = com.sun.star.sheet.ConditionOperator.EQUAL
    condition(1).Name = "Formula1"
    condition(1).Value = """Tied"""
    condition(2).Name = "StyleName"
    condition(2).Value = "Tied"
    cf.addNew(condition)
    table.setPropertyValue("ConditionalFormat", cf)
end sub

Conditional formatting is described at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Conditional_Formats. https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Conditional_Formats The operator must be of type com.sun.star.sheet.ConditionOperator, not com.sun.star.sheet.ConditionFormatOperator like in your attempt.

Here is working code using EQUAL.

sub formatTeamTable
    breaks = ThisComponent.sheets.getByName("Tiebreakers")
    table = breaks.getCellRangeByName("TeamTable")
    cf = table.getPropertyValue("ConditionalFormat")
    cf.Clear()
    dim condition(3) as new com.sun.star.beans.PropertyValue
    condition(0).Name = "Operator"
    condition(0).Value = com.sun.star.sheet.ConditionOperator.EQUAL
    condition(1).Name = "Formula1"
    condition(1).Value = """Tied"""
    condition(2).Name = "StyleName"
    condition(2).Value = "Tied"
    cf.addNew(condition)
    table.setPropertyValue("ConditionalFormat", cf)
end sub