背景画像を Excel に挿入
Contents
[
Hide
]
ワークシートの背景として画像を追加することで、ワークシートをより魅力的にすることができます。この機能は、シート上のデータを覆い隠すことなく背景のヒントを追加する特別な企業グラフィックがある場合に非常に効果的です。 Aspose.Cells API を使用して、シートの背景画像を設定できます。
Microsoft Excelでシートの背景を設定する
Microsoft Excel でシートの背景画像を設定するには (例: Microsoft Excel 2019):
-
からページレイアウトメニューで、ページ設定オプションをクリックし、バックグラウンドオプション。
-
画像を選択して、シートの背景画像を設定します。
シートの背景を設定する
Aspose.Cells でシートの背景を設定する
以下のコードは、ストリームからの画像を使用して背景画像を設定します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |