Reading Background Color Information

Discuss the spreadsheet application
Post Reply
Valareos
Posts: 2
Joined: Sat Jun 15, 2019 3:46 pm

Reading Background Color Information

Post by Valareos »

I have searched the forums and google for something that will work, but I have had no real luck. Any help will be appreciated

I am looking for a way to read the background color of a cell, and give that sell a value based on that color

Basically it is a reverse conditional.

I have a map that I have pixelated and imported into Open Office, where the intent is to give each cell a value based on neighboring cells for partial map matching by running an algorithm with the Value of the neighboring cells as a function of those cells background colors.

Thank you for your help
Open Office 4.1.6 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Reading Background Color Information

Post by Zizi64 »

I am looking for a way to read the background color of a cell, and give that sell a value based on that color

Basically it is a reverse conditional.
You can get the backdround color code from a cell by a macro code, if
- the cell was formatted by direct (manual) formatting method
- the cell was formatted by a Cell Style.

But you can not get the actual color code of a specific cell if the cell was formatted by the Conditional Formatting method.

And you can not get this information direcly (by passing the pure cell reference to your own macro function - because thít can pass the cell content only, but not the reference.
You can pass the ROW(A1) and COLUMN(A1) values, and you can get the properties of the cell based on the row and column number information.


It is not the right direction to determine the cell data based on a formatting information of the cell. The formatting property is not an exact data. Use the Cell contents to control your spreadsheet.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Valareos
Posts: 2
Joined: Sat Jun 15, 2019 3:46 pm

Re: Reading Background Color Information

Post by Valareos »

It is ok that I am not getting the exact color code. I create an index based on what it sees the result as, and use that for my calculations. Question becomes, HOW do I do it?

I got 7 different colors on the map, As long as each color returns a different value, no matter what that value is, I can assign them my own numbers, and do a relative comparison there. The color codes themselves don't actually matter, just matters that I can identify different colors
Open Office 4.1.6 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Reading Background Color Information

Post by Zizi64 »

Do not use the formatting properties as some Data. The data means: numerical or textual CONTENT of the cell. The background color is NOT a cell content.


Please upload a sample .ods file here.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Reading Background Color Information

Post by Lupp »

If a sheet made for keeping data once was badly designed using cell attributes (CellBackColor e.g.) to code for data, it urgently needs remedy. To get support in automating the conversion of attributes to real data, you may use one or another of the "introspective functions" you find here e.g.: viewtopic.php?f=21&t=2762 .

Never misuse such functions to persistently evaluate attributes as data surrogates. Copnvert once and for all. You then can easily use the actual data to set attributes for the view by ConditionalFormatting (CF).

Note: Using the introspective functions you never can read attributes applied to cells in the visible grid based on CF.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply