NamedRange.ClearFormats 方法
清除 NamedRange 控件的格式。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
Function ClearFormats As Object
Object ClearFormats()
返回值
示例
下面的代码示例向名为 NamedRange1 的 NamedRange 控件添加注释,然后提示您通过调用 ClearFormats 方法从 NamedRange1 中移除所有格式。
此示例针对的是文档级自定义项。
Private Sub SetRangeFormats()
Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
= Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
"namedRange1")
namedRange1.NoteText("This is a Formatting test", , )
namedRange1.Value2 = "Martha"
namedRange1.Font.Name = "Verdana"
namedRange1.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
namedRange1.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
namedRange1.BorderAround(, Excel.XlBorderWeight.xlThick, _
Excel.XlColorIndex.xlColorIndexAutomatic, )
namedRange1.AutoFormat( _
Excel.XlRangeAutoFormat.xlRangeAutoFormat3DEffects1, _
True, False, True, False, True, True)
If MessageBox.Show("Clear the formatting and notes?", _
"Test", MessageBoxButtons.YesNo) = DialogResult.Yes Then
namedRange1.ClearFormats()
namedRange1.ClearNotes()
End If
End Sub
private void SetRangeFormats()
{
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A1", "A5"],
"namedRange1");
namedRange1.NoteText("This is a Formatting test");
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);
namedRange1.AutoFormat(Excel.XlRangeAutoFormat.xlRangeAutoFormat3DEffects1,
true, false, true, false, true, true);
if (MessageBox.Show("Clear the formatting and notes?", "Test",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
namedRange1.ClearFormats();
namedRange1.ClearNotes();
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。