How to use fill for excel cell background color using c #?

Wherein:

using Excel = Microsoft.Office.Interop.Excel; 

I open excel and after I set the color of the first cell to transparent as follows:

xlRange = xlWorkSheet.get_Range("A1");
xlRange.Interior.Color = System.Drawing.Color.Transparent;

The problem is that it puts a white color, and the "borders" disappear. I want to put the option "Without filling", and it does not work.

I also tried this:

xlRange.Interior.Color = System.Drawing.Color.Empty;

but then he changed the cell color to black.


How can i solve this?

+5
source share
2 answers

Assuming you want to achieve the same state as the initial state of the cell (in a new sheet), use this:

xlRange.Interior.ColorIndex = 0;
+15
source

Try the following:

xlRange.Interior.Pattern = Excel.Constants.xlNone;
xlRange.Interior.TintAndShade = 0;
xlRange.Interior.PatternTintAndShade = 0;
+3
source

All Articles