1

How to change color of a cell content in an excel sheet in QT? I know we can change background of a cell , change font of cell contents, change style of cell content.

For ex : QAxObject *fontproperty = cells->querysubobject("Font"); fontproperty->setproperty("Bold",true);

What should be the parameters for changing text color in a cell?

1 Answers1

1

To change the text color of a cell content in an excel sheet, you should use the property "Color" followed by the QColor parameter that provides colors based on RGB, HSV or CMYK values, as shown in the last line of this code :

QAxObject *cell = sheet->querySubObject("Cells(int,int)", 1, 1);   
cell->setProperty("Value", value);
QAxObject* chars = cell->querySubObject("Characters(int, int)", 1, value.size());
QAxObject* font = chars->querySubObject("Font");
font->setProperty("Color", QColor(0, 176, 80)); //int r, int g, int b