You can use this simple code additionally to your conditional formatting
Sub paintBrdrs
Dim oSheet As Variant
Dim oStatInd As Variant
Dim oCursor As Variant
Dim aData As Variant
Dim oCell As Variant
Dim i&, j&
oSheet = ThisComponent.getCurrentController().getActiveSheet()
oCursor = oSheet.createCursor()
oCursor.gotoStart()
oCursor.gotoEndOfUsedArea(True)
aData = oCursor.getDataArray()
oStatInd = ThisComponent.getCurrentController().getFrame().createStatusIndicator()
oStatInd.start("Please wait...", (UBound(aData)+1))
For i = LBound(aData) To UBound(aData)
oStatInd.setValue(i)
For j = LBound(aData(0)) To UBound(aData(0))
oCell = oSheet.getCellByPosition(j, i)
'oCell.TopBorder = newBorder(aData, i, j, i-1, j) ' there is no need
oCell.RightBorder = newBorder(aData, i, j, i, j+1)
oCell.BottomBorder = newBorder(aData, i, j, i+1, j)
'oCell.LeftBorder = newBorder(aData, i, j, i, j-1) ' there is no need
Next j
Next i
oStatInd.end()
End Sub
Function newBorder(oData As Variant, currentY, currentX, testY, testX) As com.sun.star.table.BorderLine
Dim aBorder As New com.sun.star.table.BorderLine
aBorder.OuterLineWidth = 0
If (testY >= 0) And (testX >= 0) And (testY <= UBound(oData)) And (testX <= UBound(oData(0))) Then
If (oData(currentY)(currentX)<>oData(testY)(testX)) Then aBorder.OuterLineWidth = 26
EndIf
newBorder = aBorder
End Function