'Change Excel Range Background Color

i try to Change with C# the Background Color of a specific Range in an Excel Worksheet.

My Code:

    this.worksheetResult.Select();
    this.worksheetResult.Cells[1,1].Value = "Export1";
    this.worksheetResult.Range["A1:G1"].Merge();
    var Section1 = this.worksheetResult.Range["A1:G1"];
    Section1.Interior.Color = Colors.LightBlue;

Eyerything I tried wont work. either a HResult error shows up, or this Error Message:"Value does not Fall within the expected range."

Could need some quick help.



Solution 1:[1]

I solved already the Problem. I used the System.Drawing Library but in

Section1.Interior.Color = Colors.LightBlue;

"Colors" there was used another Library that shouldn´t. So i just addes the correct Library before Colors.

Solution 2:[2]

Which library are you using to accomplish this? And have you tried to debug to get the exact line where the error occur?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tomi Horvath
Solution 2 sMuLe