Keith Clark
Keith Clark

Reputation: 609

c# Output WinForm to Excel

Have researched outputting to Excel and can successfully do so. My question is more if I am missing something simpler.

Currently, if I want to set the font, cell color, size, etc. of a single cell, I am doing so like this:

        range = (Range)ws.Cells[10, 12];
        range.Formula = "=SUM(R10C10:R10C11)";
        range.Calculate();
        range.Font.Bold = true;
        range.Font.Underline = true;
        range.Style = wb.Styles["Currency"];
        range.Font.Color = Color.Red;
        range.Font.Name = "Arial";
        range.Font.Size = 26;
        borders = range.Borders;
        borders.LineStyle = XlLineStyle.xlContinuous;
        borders.Weight = 2d;

Did I miss something in the documentation that allows me to do this on a SINGLE cell without having to create a Range?

Upvotes: 1

Views: 51

Answers (1)

Absinthe
Absinthe

Reputation: 3391

No, C# requires an object qualifier (see What's the C# equivalent to the With statement in VB?. So your current code is to protocol.

Upvotes: 1

Related Questions