Coloring cells based on cell value in OpenOffice
OpenOffice (probably LibreOffice too) has limited functionality for setting the background color of a cell. I wrote a little macro that colors each cell blue, with saturation depending on the range of the value. This is in OOBasic, but it demonstrates the general idea, and the proper way of setting cell background colors.
Sub Main
End Sub
sub ColorCells
dim ii
dim jj
dim r
dim g
dim b
dim doc as object
dim sheet as object
dim cell as object
doc = ThisComponent
sheet = doc.Sheets.getByName("Sheet1")
for ii = 0 to 5
for jj = 0 to 626
cell = sheet.getCellByPosition(ii, jj)
r = 255 - (cell.Value * 255)65536
g = 255 - (cell.Value * 255)65536
b = 255
cell.CellBackColor = RGB(r,g,b)
next jj
next ii
end sub
Recent Comments