ChartSheet.ProtectContents 屬性

取得值,指出 Microsoft.Office.Tools.Excel.ChartSheet 的內容是否受到保護。

命名空間:  Microsoft.Office.Tools.Excel
組件:   Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)
  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
ReadOnly Property ProtectContents As Boolean
bool ProtectContents { get; }

屬性值

型別:System.Boolean
如果 Microsoft.Office.Tools.Excel.ChartSheet 的內容受到保護,則為 true。

備註

這會保護整個 Microsoft.Office.Tools.Excel.ChartSheet

範例

下列程式碼範例會使用 Protect 方法來保護目前 Microsoft.Office.Tools.Excel.ChartSheet 的所有內容。 這個範例接著會使用 ProtectContents 屬性來驗證圖表是否受到保護,然後提示使用者利用 Unprotect 方法取消對圖表的保護。

Private Sub ChartSheetProtection()
    Globals.Sheet1.Range("A1", "A5").Value2 = 22
    Globals.Sheet1.Range("B1", "B5").Value2 = 55

    Me.SetSourceData(Globals.Sheet1.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    Me.ChartType = Excel.XlChartType.xl3DColumn

    Me.Protect(DrawingObjects:=True, Contents:=True, _
        Scenarios:=True, UserInterfaceOnly:=False)

    If Me.ProtectContents Then
        If DialogResult.Yes = MessageBox.Show("The chart sheet" & _
            " is protected. Unprotect the chart sheet?", _
            "Example", MessageBoxButtons.YesNo) Then
            Me.Unprotect()
        End If
    End If
End Sub
private void ChartSheetProtection()
{
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
        Excel.XlRowCol.xlColumns);
    this.ChartType = Excel.XlChartType.xl3DColumn;

    this.Protect(true, true, true, false);

    if (this.ProtectContents)
    {
        if (DialogResult.Yes ==
            MessageBox.Show("The chart sheet is protected. " +
            "Unprotect the chart sheet?", "Example", 
            MessageBoxButtons.YesNo))
        {
            this.Unprotect();
        }
    }
}

.NET Framework 安全性

請參閱

參考

ChartSheet 介面

Microsoft.Office.Tools.Excel 命名空間