Donate

How To Set Background Color Of Excel Cell Using C#

Good evening!

Here's how to set MS Excel cell or cells background color using C# Excel.Range class in two different solutions.
chartRange = sheet.Cells[1, i + 1];  
 chartRange.Interior.Color = Color.LightBlue;
or using get_Range() function and ColorTranslator.ToOle() to set the background color.
Excel.Range chartRange;
chartRange = xlWorkSheet.get_Range("b1", "b3");
chartRange.Interior.Color = ColorTranslator.ToOle(Color.Red);
Where chartRange is a RangeObject.
How To Set Background Color Of Excel Cell Using C#

Comments

  1. Gud Job.. it z working . Thank u

    ReplyDelete
  2. try this...

    Excel.Range formatRange;
    formatRange = xlWorkSheet.get_Range("b1", "b1");
    formatRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

    More info....Excel Cell Formatting

    Ling



    ReplyDelete

Post a Comment

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.