Documents for Excel, Java Edition Documentation
Features / Shapes And Pictures / Background Image
In This Topic
    Background Image
    In This Topic

    GcExcel allows you to set background image in a worksheet using the setBackgroundPicture method of the IWorksheet 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.

    Copy Code
     Workbook workbook = new Workbook();
    // Fetch default worksheet
    IWorksheet worksheet = workbook.getWorksheets().get(0);
    worksheet.getRange("A1").setValue("GrapeCity Documents for Excel");
    // Load an image from a specific file in input stream
    InputStream inputStream = new FileInputStream("grapecity.png");
    try {
        byte[] bytes = new byte[inputStream.available()];
        // Read an image from input stream, 0, bytes.length);
        // Add background image of the worksheet
    } catch (IOException ioe) {
    // Save workbook"PrintBackgroundPicture.xlsx", SaveFileFormat.Xlsx);

    The background image can also be included while exporting the worksheet to PDF documents. For more information, refer to Support Sheet Background Image in this documentation.