Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
Flexcel is not based on VBA since it is a .NET library that provides Excel file manipulation abstractions : tmssoftware.com/site/flexcelnet.asp –  Matthieu Durut May 24 '13 at 18:38
    
You could remove the conditional format from the cells where you apply Flexcel. –  teylyn May 25 '13 at 4:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.