Excelに背景画像を挿入する

Microsoft Excelでのシートの背景の設定方法(例:Microsoft Excel 2019):

  1. ページレイアウトメニューからページの設定オプションを見つけ、背景オプションをクリックします。

  2. ページレイアウトメニューからページ設定オプションを見つけ、背景オプションをクリックします。

  3. シートの背景画像を設定するために画像を選択します。

    シートの背景を設定する

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

関連記事