Excel Interop: Fastest way to change color of portions of text in a huge range of cells
- by Kyopaxa
There some articles about the fastest way to write data using Excel interop assigning directly an Array of data to the value of the range. Like:
string[,] multidimensionalArrayData = new string[200, 3];
// (...) Fill multidimensionalArrayData with your data
dataSheet.Range["A1:C200"].Value = multidimensionalArrayData;
There are also some articles about how to change the Font color of a specific portion of text, for example (VB this time):
With ActiveCell.Characters(Start:=3, Length:=3).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Color = "Red"
.ThemeFont = xlThemeFontNone
End With
The question now is, what would be the fastest way to change the color of specific portions of text for thousands of cells? Currently, in my C# code, I have to do it cell by cell, with a horrible performance hit. Is there a way to fill an array of 'Characters' objects in C# and pass that array to a range in one go? Any other solutions?