c# – microsoft.interop.excel格式化单元格

前端之家收集整理的这篇文章主要介绍了c# – microsoft.interop.excel格式化单元格前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用C#中的microsoft.interop.excel库构建报告.

我有这样的东西:

Range rangeTarget;
 .
 .
 .
 rangeTarget = worksheet.get_Range("C" + row,"N" + row);

我希望范围显示其值作为整数,即没有小数位.
我已经尝试了rangeTarge.AutoFormat,但不知道如何使用它.

有任何想法吗 ?

谢谢.

解决方法

MSDN
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A1","A5"],"namedRange1");

namedRange1.NoteText("This is a Formatting test",missing,missing);
namedRange1.Value2 = "Martha";
namedRange1.Font.Name = "Verdana";
namedRange1.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
namedRange1.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
namedRange1.BorderAround(missing,Excel.XlBorderWeight.xlThick,Excel.XlColorIndex.xlColorIndexAutomatic,missing);
namedRange1.AutoFormat(Excel.XlRangeAutoFormat.xlRangeAutoFormat3DEffects1,true,false,true);

if (MessageBox.Show("Clear the formatting and notes?","Test",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
    namedRange1.ClearFormats();
    namedRange1.ClearNotes();
}
原文链接:https://www.f2er.com/csharp/94325.html

猜你在找的C#相关文章