jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.48k stars 330 forks source link

Implement the $book->set_custom_color() function from the Perl library in the C library #424

Closed GavinMGlynn closed 4 months ago

GavinMGlynn commented 8 months ago

Feature Request

Hi

I work for a company that has made extensive use of the original Perl library. They actually wrote their own C wrapper around the Perl library to give them XLSX generation capabilities in C. Now, I am thinking to "cut out the middle man" and just use your C library directly. The only wrinkle is quite a bit of our existing code relied upon the $book->set_custom_color() functionality.

In pretty much every case, a spreadsheet is being generated for a customer, which they will eventually forward back to my company. The set $book->set_custom_color() functionality is used to set the customers color palette in the spreadsheet and then is referred to it in each format.

Thanks

Gavin Glynn :)

PS: I am happy to help make the change, if needed.

jmcnamara commented 8 months ago

I'll have a look at it soon.

jmcnamara commented 4 months ago

I finally got around to looking at this feature request and unfortunately it isn't feasible in the C version of the library.

A long time time ago, I implemented the set_custom_color() method in Excel::Writer::XLSX version to account for similar functionality in the my older XLS writing Spreadsheet::WriteExcel library. It was necessary in the older version because Excel had a limited color palette of ~ 64 colors and that was the only way to change them.

However in the XLSX format Excel supported 16 million RGB colors so that form of custom color functionality was no longer required. As a result I didn't port it to any of the subsequent Python, C or Rust libraries. And at this point in time it doesn't make sense to retrofit it. Sorry about that.

As a workaround you could possibly use named variables for each color you need and modify the RGB value based on the customer.

Closing as won't fix