Hello , Everyone.
Using LibreOffice 5 or 6 Macros (Basic), if the DATE data in the cell range (A3: A200) is in the past 7 days,
I want to be red the background color of these cells.
But, I can not find any missing beans properties (= name and value).
The cell range (A3: A200) attributes are “serial-based date” and the format are “yy/mm/dd”.
LibreOffice Version No is 6.2.3.2 or 5.0.5.2
The style “BackgroundColorR” is pre-defined.
The current code is as follows
Sub SetRedStyle()
Dim oRange as object
Dim oConFormat
Dim oCondition(2) As New com.sun.star.beans.PropertyValue
oRange = ThisComponent.Sheets(1).getCellRangeByName("A3:A200")
oConFormat = oRange.ConditionalFormat
oCondition(0).Name = "SourcePosition"
oCondition(0).Value = oRange.getCellByposition(0,0).getCellAddress()
oCondition(1).Name = "Operator"
oCondition(1).Value = com.sun.star.sheet.DateType.LAST7DAYS
oCondition(2).Name = "StyleName"
oCondition(2).Value = "BackgroundColorR"
oConFormat.addNew(oCondition())
oRange.ConditionalFormat = oConFormat
End Sub
[Status]
1.All input cells turn red.
2.When I check the conditional format created by a macro,
they are made like “Cell value is”,“Greater than the next value” and “next value = 0”
3.When I set this conditional formatting manually,
they are created correctly. When I check them,they are made conditional format like
“Date is”,“The values of cells are within the last 7 days”
link text
I ask the same question in Japanese,above link.
I corrected the link address to the question. 2019/06/09 16:05 JST
I received the first answer from Mr.himajin 100000 on the Japanese site.
And the number of links in the source text with the description is huge and I can not understand the whole story or details.
Please follow the URLs in order, just in case.
it would be not implemented in LibreOffice side, at least he answered that you can’t solve that problem in this way, it would be a LibreOffice bug.
In the first place, this structure does not hold information about dates.
https://opengrok.libreoffice.org/xref/core/sc/inc/fmtuno.hxx?r=09c657eb#49
This structure is probably “ScCondFormatEntryItem”.
Please check the link at the end of the answer.
There are two parts that I felt strange looking at LibreOffice Module sc (master): conditio.hxx Source File
from the link at the end.
1.line239
It is part of “enum class Type”. “Date” can be linked somewhere, but when it is clicked it becomes 404 Not Found.
2.line283
There are descriptions of the switch statement from line 265 to line 288, but the word following Type :: in the case statement and the word following “<<” in the stream statement on the next line have the same five other words 283 Only the line is different. The case statement is “Date” but the stream statement is “Data”. Is this probably causing a bug due to a typo?
That’s all, thanks.