WorksheetBase.SetBackgroundPicture Method (String)

 

Sets the background graphic for the worksheet.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public void SetBackgroundPicture(
	string filename
)

Parameters

filename
Type: System.String

The name of the graphic file.

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.");
    }
}
Return to top
Show: