I need how does the COLOR function work? I need to output the color value of a
table cell to another table cell.
Could you please tell us, what is unclear with the information given in LibreOffice help - COLOR?
> I need to output the color value of a table cell to another table cell.
This requires a macro because COLOR()
just turns a (r;g;b[;alpha]) tuple into a decimal value but you need to get the (background) color of a cell. In other words: Function COLOR()
does not support your task at all.
Thanks for the reply. Since the table is not large, I by hand wrote the color value of the cell to the another cell.
Hello,
a simple user function could look like this (this is not an elaborated solution, just an outline):
Function GETBGCOLOR(sCellAddr as String)
Dim oSheet As Object
Dim oCell As Object
On Error Resume Next
oSheet = ThisComponent.CurrentController.ActiveSheet
oCell = oSheet.getCellRangeByName(sCellAddr)
GETBGCOLOR = oCell.CellBackColor
End Function
and could be called by:
[1] =GETBGCOLOR(CELL("address";A1))
(preferred, can be copied with regular address adaption) –or–
[2] =GETBGCOLOR("A1")
(needs to be adapted, if A1 should be relative)
See also following sample file, which contains the user function: GETBGCOLOR.ods