将背景图像插入Excel

在Microsoft Excel中设置工作表背景

在Microsoft Excel(例如Microsoft Excel 2019)中设置工作表的背景图片:

  1. 页面布局菜单中找到页面设置选项,然后点击背景选项。

  2. 选择一张图片来设置工作表的背景图片。

    设置工作表背景

todo:image_alt_text

使用Aspose.Cells设置工作表背景

下面的代码使用从流中读取的图像设置了一个背景图像。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// Create a new Workbook.
Workbook workbook = new Workbook();
// Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);
// Get the image file.
File file = new File("background.jpg");
// Get the picture into the streams.
byte[] imageData = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(imageData);
// Set the background image for the sheet.
sheet.setBackgroundImage(imageData);
fis.close();
// Save the excel file
workbook.save("SBPforWorksheet.xlsx");

相关文章