Share via


WorksheetBase.SetBackgroundPicture 方法

設定工作表的背景圖形。

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

語法

'宣告
Public Sub SetBackgroundPicture ( _
    filename As String _
)
public void SetBackgroundPicture(
    string filename
)

參數

範例

下列程式碼範例會使用 SetBackgroundPicture 方法,將工作表的背景影像設定為名為 image1.jpg 的檔案。

這是示範文件層級自訂的範例。

Private Sub SetWorksheetPicture()
    Dim backgroundFilePath As String = "C:\image1.jpg"
    If System.IO.File.Exists(backgroundFilePath) Then
        Me.SetBackgroundPicture("C:\image1.jpg")
    Else
        MsgBox("The file C:\image1.jpg does not exist.")
    End If
End Sub
private void SetWorksheetPicture()
{
    string backgroundFilePath = @"C:\image1.jpg";

    if (System.IO.File.Exists(backgroundFilePath))
    {
        this.SetBackgroundPicture(@"C:\image1.jpg");
    }
    else
    {
        MessageBox.Show(@"The file C:\image1.jpg does not exist.");
    }
}

.NET Framework 安全性

請參閱

參考

WorksheetBase 類別

Microsoft.Office.Tools.Excel 命名空間