Inserisci un'immagine di sfondo in Excel
Contents
[
Hide
]
Puoi rendere un foglio di lavoro più accattivante aggiungendo un’immagine come sfondo del foglio di lavoro. Questa funzione può essere molto efficace se si dispone di una grafica aziendale speciale che aggiunge un accenno di sfondo senza oscurare i dati sul foglio. È possibile impostare l’immagine di sfondo per un foglio utilizzando Aspose.Cells API.
Impostazione dello sfondo del foglio in Microsoft Excel
Per impostare l’immagine di sfondo di un foglio in Microsoft Excel (ad esempio, Microsoft Excel 2019):
-
DalLayout di pagina menu, trova ilImpostazione della pagina opzione, quindi fare clic suSfondo opzione.
-
Seleziona un’immagine per impostare l’immagine di sfondo del foglio.
Impostazione di uno sfondo del foglio
Impostazione dello sfondo del foglio con Aspose.Cells
Il codice seguente imposta un’immagine di sfondo utilizzando un’immagine da un flusso.
This file contains 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"); |