简体   繁体   中英

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 ?

不,C# 需要一个对象限定符(请参阅与 VB 中的 With 语句等效的 C# 是什么? 。所以您当前的代码是协议。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM