0
votes

I want to modify the colors of some cells in an already filled Excel spreadsheet using the method:

FlexCel.Adapter.XlsFile.SetCellFormat(int row1, int col1, int row2, int col2, int XF);

The colors are not always correctly displayed since the cells I modify are sometimes subject to Conditional Formatting rules that override background and foreground colors.

In Excel, there is a functionality to prevent a rule from being applied on a specific cell. Is there such a functionality in Flexcel?

1
Are you using xls files or xlsx files? I'm almost certain that with Flexcel, you need to keep the file format in xls to maintain the conditional formatting. Xlsx will strip it of the conditional formatting. - Joshua Schlichting

1 Answers

0
votes

What is FlexCel? You may want to provide a link to this tool or describe what it does.

In general, direct cell formatting and conditional formatting are two different things.

You can apply a cell format (and I assume that FlexCel is an add-in that uses VBA to set the cell format) and the cell will show it.

Conditional formatting will override any direct cell formatting if the condition is met. It does not matter how the original cell format was arrived at. Whether or not the cell has been formatted manually or with a VBA routine or an add-in like FlexCel is insubstantial.

From the code snippet you posted it is apparent that the cell format is set with VBA. If a conditional format is applied to the cell, that will override the format applied by VBA.

If you don't want that, you will need to extend the VBA code to include/exclude your specific conditions instead of using conditional formats.