Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

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:
C#
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): Change font colour of specific text with Excel interop
VB
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?
Posted
Updated 29-Jun-12 17:59pm
v3
Comments
Sunny_Kumar_ 21-Jun-12 4:37am    
Hi Kyopaxa, can you please explain what do you mean by -"to pass an array of 'Characters' objects to a range" ?
Kyopaxa 29-Jun-12 23:45pm    
Hi Sunnykumar,
With Excel VBA you change the color of a portion of the text of a cell by using its Characters object. (See the link 'Change font colour of specific text with Excel interop' above)
Currently, I have to modify the Characters object of every cell, one by one, with a tremendous hit in performance.
I am wondering if there is a way to modifying an array of Characters objects in my C# code, then pass the array already modified to a range of cells at once.
Subramanyam Shankar 16-Mar-15 13:54pm    
you can get the range of cells using interop dll and change the color of specific portions in that range.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900