-
-
Notifications
You must be signed in to change notification settings - Fork 400
Description

#include <QXlsx/xlsxdocument.h>
#include <QDebug>
int main()
{
// theme-fill.xlsx: A1 is filled with Accent 1 + 60 % lighter
QXlsx::Document x("theme-fill.xlsx");
x.load();
const auto fmt = x.cellAt(1, 1)->format(); // A1
qDebug() << "bg =" << fmt.patternBackgroundColor()
<< "fg =" << fmt.patternForegroundColor()
<< "prop32 =" << fmt.property(32) // P_Fill_FgColor
<< "prop33 =" << fmt.property(33); // P_Fill_BgColor
}
Console output
bg = QColor() fg = QColor()
prop32 = QVariant(QXlsx::XlsxColor, XlsxColor(theme,"4:-0.249977111117893") )
prop33 = QVariant(QXlsx::XlsxColor, XlsxColor(indexed,64) )
Expected behaviour
For a cell whose fill is defined via a theme colour (here: Accent 1, 60 % lighter), I would expect some public API to return the resolved (≈ ). The same applies to theme-based font colours.QColor#B4C6E7
What I tried
patternBackgroundColor() / patternForegroundColor() only work when the colour is stored as an explicit in styles.xml. With they always return an invalid .<rgbColor …>QColor
Using / I do receive a that contains , so the theme index and tint are parsed.Format::property(32)property(33)QVariantXlsxColor(theme,"…")
At the moment the only working solution is to include the private headers and , then call to obtain the final RGB value. This relies on private API and may break on updates.xlsxcolor_p.hxlsxstyles_p.hXlsxColor::rgbColor(styles)
Questions / suggestions
Is there an officially supported, public function to convert a theme-based fill or font colour to a ?QColor
If the conversion must go through , would it be possible to expose (or a similar helper) in the public API?StylesXlsxColor::rgbColor()
Thanks for your time and for maintaining QXlsx!