## 16,777,216 cells

### 16,777,216 cells

I would like to create a sheet with all html color codes.
There are 16,777,216.
Can anybody help me? Thanks.
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

Are the color codes in binary, octal, decimal or hexidecimal?
Can you provide an example of what the code should be (an example along with the equivalent colour would be great)
Are you wanting to see the color as well as the code?
You might want to consider looking in the Help file, when accessed from Calc, at Colors -> Selection
OpenOffice 4.1.7 and LibreOffice 6.3.3.2 on Windows 7 Pro & Ultimate
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.

RusselB
Moderator

Posts: 6103
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

### Re: 16,777,216 cells

Hi, and welcome to the forum.

x-x51h wrote:I would like to create a sheet with all html color codes. There are 16,777,216.
This Perl program will create an HTML file which contains all 16777216 colors. Whether you can open it in your browser depends on your hardware and software. It may take quite a while. If successful you can copy/paste the table into an empty spreadsheet. Whether that will be successful depends on your hardware and software. It may take quite a while.

`# Create 65536 rows by 256 columns table of colorsuse strict; use warnings;my (\$rows,\$cols,\$r,\$r0,\$r1,\$c,\$foreRGB,\$backRGB);# Optional first parm reduces number of rows by that factor# For example 10000 creates 7 rows = ROUNDUP(65536/10000)\$rows = 1; \$rows=\$ARGV[0] if \$#ARGV >= 0;# Optional second parm reduces number of columns by that factor\$cols = 1; \$cols=\$ARGV[1] if \$#ARGV >= 1;sub f { return (shift()+128)%256 }print qq[<?xml version="1.0" encoding="UTF-8"?>].      qq[<html xmlns="http://www.w3.org/1999/xhtml"><body><table>\n];for (\$r=0;\$r<65536;\$r+=\$rows) {   \$r0 = \$r>>8; \$r1 = \$r-(\$r0<<8);   print qq[<tr>\n];   for (\$c=0;\$c<256;\$c+=\$cols) {      \$backRGB = sprintf('%02X'x3,\$r0,\$r1,\$c);      \$foreRGB = sprintf('%02X'x3,&f(\$r0),&f(\$r1),&f(\$c));      print qq[<td style="width:0.75in;color:#\$foreRGB;].            qq[background-color:#\$backRGB;">#\$backRGB</td>\n];   }   print qq[</tr>\n];}print qq[</table></body></html>\n];`

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800 on MacOS 10.14.6.   The locale for any menus or Calc formulas in my posts is English (USA).

MrProgrammer
Moderator

Posts: 3960
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

### Re: 16,777,216 cells

I do not know, why you need that.

But I know that the LibreOffice Calc sheet has max. 1,048,576 rows "only", and max. 1024 columns "only", and a spreadshees document can store 10000 sheets "only".
Theese fact mean: There are enough cells for this task on a single sheet, but you must use more than one sheet for a clear structure, or you need use a strange structure on one sheet for storing the color codes, because the color codes are in a three dimensional matrice (RGB - 256*256*256).
Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.5;AOO4.1.7
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.

Zizi64
Volunteer

Posts: 9533
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

### Re: 16,777,216 cells

hi. Thanks for your answers. I'm thinking in something like these tables that you can find on Wikipedia: https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

It would be interesting to know why you want to do this.

I ask because there may be better ways of doing what you actually want to do which don't involve compiling such a large spreadsheet.

The XY problem is where you want to do X but you cannot. You guess a solution Y which is probably not a good idea. You then try to fix Y.

It is far better to say "I want to do X ..." and consider all your options first so you don't get drawn down the dead end of Y.

It is always better to ask what you want to do rather than guessing a solution which is? may be? wrong? not optimal?, and then trying to get your guessed wrong or non-optimal solution to work.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer

Posts: 7792
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

### Re: 16,777,216 cells

I am trying to build a community open source project.
The target of this project is to name all the colors and to use those names in css style sheets and that browsers are able to read these name of colors.
Lovely idea but so difficult to build.
Anybody is interested in the project?
Thanks
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

Where will you get 16777216 reasonable "names" from?
I would think the only practicable names for colours defined in the RGB-scheme under the conditions we find are the RGB triples in one or another representation. Html-colour-codes do exactly this with two "hex" digits per RGB-component, the order and the split being implicit. To get legal "names" under a given sntax you may need to use a different prefix instead of "#".
On Windows 10: LibreOffice 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München

Lupp
Volunteer

Posts: 2913
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

### Re: 16,777,216 cells

What I mean is this...
For example, you can write #FFFF00 to name a color in your css file.
But you can also write "yellow" and the browsers will understand this name.
So my project try to "name" any of the more than 16 million colors.
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

So that´s because I need a spreadsheet before starting the project.
Any color has a html, hex, rgd, cmyk... name.
But not a "real" name, like "yellow", "orange", "light blue"...
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

I cannot believe that.
You actually want to define a "trivial name" for each one of 16777216 colours where there will be billions of pairs a human eye cannot see any difference between?
To create a sheet containing cells with all the 24-bit-colours as the CellBackColor(s) of different cells is simple - in principle. Doing it with a little BASIC Sub will, however, need a few days on a standard computer.

Code: Select all   Expand viewCollapse view
`Sub setR_GBtheSheet = ThisComponent.Sheets(0)fa = CreateUnoService("com.sun.star.sheet.FunctionAccess")Dim hex(0 To 255) As StringFor i = 0 To 255    hex(i) = fa.CallFunction("Dec2Hex", Array(i, 2))Next iFor R = 0 To 255    Rhex = hex(R)    For G = 0 To 255        Ghex = hex(G)        For B = 0 To 255            Bhex = hex(B)            cName = "RGB" &  Rhex & Ghex & Bhex            oneCell = theSheet.GetCellByPosition(R, G * 256 + B)            oneCell.CellBackColor = (R * 256 + G) * 256 + B            oneCell.String = cName        Next B    Next GNext REnd Sub`
On Windows 10: LibreOffice 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München

Lupp
Volunteer

Posts: 2913
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

### Re: 16,777,216 cells

OK. I will try to explain this project again.
I am trying to build a webpage or app in where any user can name any html color.
So I need to link a spreadsheet containing all the html color codes within this webpage or app.
The users will name the colors. Not the system or you or me.
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

x-x51h wrote:The users will name the colors. Not the system or you or me.

I think I was aware of that idea. But how should it evade the obstructive facts I mentioned?
On Windows 10: LibreOffice 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München

Lupp
Volunteer

Posts: 2913
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

### Re: 16,777,216 cells

Well. To be honest, I am not very good in maths, or spreadsheets or webpages.
I just have an idea. But I don't how to build it up.
Apache OpenOffice 4.1.4
Windows 7 x86
x-x51h

Posts: 10
Joined: Wed Dec 13, 2017 10:53 pm

### Re: 16,777,216 cells

Likelihood is that you would never need to use all of those colours. Having said that, there are a number of resources online having lists of colour names and the related RGB and Hex values - see https://duckduckgo.com/?q=list+of+color ... 5a_&ia=web

There are also online colour pickers - https://duckduckgo.com/?q=color+pickers ... 5a_&ia=web
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine

robleyd
Moderator

Posts: 3456
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

### Re: 16,777,216 cells

The users will name the colors. Not the system or you or me.

I just played with the Red-Green combinations (by a macro with constant zero Blue value). Here is a lot (but not all!) of the possible color shades. All of the filled-in cells of this sheet has a different background color from the RGB(0,0,0) to RGB(255,255,0). This means 65536 different colors. You can see only a few thousands of the colors on the attached picture.

How they will name all of them?????

Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.5;AOO4.1.7
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.

Zizi64
Volunteer

Posts: 9533
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

### Re: 16,777,216 cells

Zizi64 wrote:
How they will name all of them?????

If it takes 10 seconds to name each one, and someone works at it for 12 hours per day, 7 days per week, it will take them almost eleven years.

On the other hand, why not use the RGB values? White is 255255255, black is 000000000 and red is 255000000. Red with a smidgen of blue is 255000001 and red with two smidgens of blue is 255000002. Bingo! You have computer generated unique names.

I am warming to the theme. Name each of the 256 reds with a name. eg 255 can be red, 128 can be light_red, 001 can be smidgen_red etc. Do the same for the blues and the greens. Now catenate the three names. You now have unique names like "light_red smidgen_green blue" which can be computer generated.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer

Posts: 7792
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

### Re: 16,777,216 cells

x-x51h wrote:OK. I will try to explain this project again.
I am trying to build a webpage or app in where any user can name any html color.
So I need to link a spreadsheet containing all the html color codes within this webpage or app.
The users will name the colors. Not the system or you or me.

For a spreadsheet of this magnitude, you may encounter problems with OpenOffice. The size may exceed 4 GB, which AFAIK cannot be handled by 32 bit software. Consider using LibreOffice...

To the subject matter: What is the purpose of this? Is it ...
1. ... a "collaborative effort" where we will end up with just short of 17 million different names, decided by a number of "authorised" users and available for everyone to use?
2. ... a tool anyone can use to pick any color(s) they like, and set a name they can use in their own work?
3. ... something entirely different?
For 1:
Consider this: English is one of the languages in the world with the largest count of available words. Rough estimates indicate somewhere between 200000 to 1 million distinct words (actual number depends on what you count as "English" and "distinct"). Most languages, including English, have less than 10000 words in common everyday use. How much sense does it make to build a "color vocabulary" roughly 80 times the magnitude of the entire language?
For useability: You will get many different names for very similar (not humanly discernible) colors. You will get identical names for vastly different colors.

For 2:
An equivalent tool is usually already available in the context where it is needed. Most software with a graphical perspective (including print setup and web layout software) have a palette tool where you can pick any color from a "rainbow circle" or similar, or entered by RGB/CMYK/HSL values. The color can be saved in a palette cell. Some tools also allow naming of each cell in a custom palette, and even saving different palettes for future use.
Recreating this in a spreadsheet may be a rewarding exercise, but I don't see how it transfers to a useful tool, be it a spreadsheet or a standalone app. (Then again, there are quite a few things I don't see, and that doesn't mean that they don't exist...)

For 3:

keme
Volunteer

Posts: 3367
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway