Share via


WorksheetBase.SetBackgroundPicture(String) Method

Definition

Sets the background graphic for the worksheet.

public:
 void SetBackgroundPicture(System::String ^ filename);
public void SetBackgroundPicture (string filename);
member this.SetBackgroundPicture : string -> unit
Public Sub SetBackgroundPicture (filename As String)

Parameters

filename
String

The name of the graphic file.

Examples

The following code example uses the SetBackgroundPicture method to set the background image of the worksheet to a file named image1.jpg.

This example is for a document-level customization.

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.");
    }
}
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

Applies to