# Background Image

Learn how to the set the background image in a worksheet using DsExcel with a sample code.

## Content

DsExcel allows you to set background image in a worksheet using the [setBackgroundPicture](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IWorksheet.html#setBackgroundPicture) method of the [IWorksheet](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IWorksheet.html) interface. The background image can be saved to Excel and is rendered multiple times, side by side, to cover the whole area of the worksheet.

### Using Code

Refer to the following example code to save sheet background image in Excel.

```Java
Workbook workbook = new Workbook();
// Fetch default worksheet
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("A1").setValue("Document Solutions for Excel");
worksheet.getRange("A1").getFont().setSize(25);

// Load an image from a specific file in input stream
InputStream inputStream = new FileInputStream("background-image.png");
try {
    byte[] bytes = new byte[inputStream.available()];
    // Read an image from input stream
    inputStream.read(bytes, 0, bytes.length);

    // Add background image of the worksheet
    worksheet.setBackgroundPicture(bytes);
} catch (IOException ioe) {
    ioe.printStackTrace();
}

// Save workbook
workbook.save("PrintBackgroundPicture.xlsx", SaveFileFormat.Xlsx);
```

![worksheet-background-image](https://cdn.mescius.io/document-site-files/images/871475f5-000f-4c6f-884e-8b80466fda96/worksheet-background-image.ce90c0.png)

The background image can also be included while exporting the worksheet to PDF documents. For more information, refer to [Support Sheet Background Image](/document-solutions/java-excel-api/docs/online/ManageFileOperations/ExporttoaPDFFile/support_sheet_background_image) in this documentation.