I made a code change recently to update several cells at once for performance reasons. The code looks like:
private static void SetRangeValues(Worksheet sheet, int row, int col, object[] cellData)
{
var range = sheet.GetCell(row, col);
range = range.get_Resize(1, cellData.Length);
range.Value = cellData;
}
This works fine, but if there are multiple cells being updated, which there pretty much always are, then any Conditional Formatting that exists in the cells is not applied without manually going into the cells and re-applying the Conditional Formatting - which of course the user is not willing to do. The only way I can get it to work properly is to go back to setting the value one cell at a time, which is not an option.
I have tried setting and toggling the worksheet.EnableFormatConditionsCalculation (no effect), looping through the range.FormatConditions enumerator and setting the ModifyAppliesToRange to another cell and back (blows up with an "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" exception). Any ideas?