Reputation: 155
How can I get hold of the displayed format of a cell in excel interop 2007. I have a cell where the font's boldness is depending on the value in another cell. No matter if the condition is met or not, the cell.Font.Bold and cell.Style.Font.Bold properties are always false. (cell is of type Range). So is there a way to query the cell's style as the user would see it in Excel?
workbook = application.Workbooks.Open(fileName);
var worksheet = (Worksheet)workbook.Worksheets["Test"];
var cell = (Range)worksheet.Cells[8, 3];
var style = (Style)cell.Style;
strb.AppendLine("Bold: " + cell.Font.Bold); // -> False
strb.AppendLine("Bold: " + style.Font.Bold);// -> False
I also tried using the FormatConditions, but there I haven't found a way to know whether the conditions are met.
Cheers
Wullie
Upvotes: 1
Views: 735
Reputation: 2194
Unfortunately Excel doesn't give you functions 'out of the box' to tell you which conditions have been met. The best code I've seen that will tell you which conditions are active is Chuck Pearson's ActiveCondition code. You'll have to translate it from VBA to C#.
Upvotes: 2