Using the CAxlsx gem (https://github.com/caxlsx/caxlsx), I'm trying to add conditional formatting to a range of cells, where the style should be applied if the cell contains the character -. Here's the snippet I'm using at the moment.
worksheet.add_conditional_formatting(range,
type: :containsText,
formula: "-",
dxfId: @styles[:invalid],
priority: 1)
Unfortunately, this doesn't seem to work. It does seem to apply the styling when the cell doesn't contain text, but a negative number, but that's not my use case. The documentation is severely lacking as well, and it doesn't offer a lot of explanation on what should be done in this case. (E.g., there's a cellIs type, with which the containsText operator can be used, but there's also a containsText type and no explanation as to what the difference between them is - and neither seem to work in my case.) Any pointers would be greatly appreciated, so far it's just been trial and error.
Assuming your range is something like
"A1:A4"then formula you are looking for isNOT(ISERROR(SEARCH("-",A1))). DocsExample:
I have found that the easiest way to determine the appropriate formula is to: