Aggiungere un immagine a un commento di Excel
Microsoft Excel consente agli utenti di personalizzare l’aspetto e la sensazione dei fogli di calcolo in gran parte. È anche possibile aggiungere immagini di sfondo ai commenti.
I commenti vengono aggiunti alle celle per registrare commenti, dalle informazioni su come funziona una formula, da dove proviene un valore o domande da parte dei revisori. Aggiungere un’immagine di sfondo può essere una scelta estetica o essere utilizzata per rafforzare il marchio.
Aggiungi immagine al commento di Excel con Microsoft Excel
Con Microsoft Excel 2007, è possibile avere un’immagine come sfondo per un commento di cella. In Excel 2007, questo si realizza (supponendo che il commento sia già stato aggiunto) in questo modo:
- Fare clic con il pulsante destro del mouse sulla cella che contiene il commento.
- Scegliere Mostra/Nascondi commenti e cancellare eventuali testi dal commento.
- Fare clic sul bordo del commento per selezionarlo.
- Scegliere Formato, quindi Commento.
- Nella scheda Colori e linee, fare clic sulla freccia per Colore.
- Fare clic su Effetti di riempimento.
- Nella scheda Immagine, fare clic su Seleziona immagine.
- Trova e seleziona l’immagine
- Fai clic su OK.
Aggiungi immagine al Commento di Excel con Aspose.Cells
Aspose.Cells fornisce questa caratteristica preziosa.
Il codice di esempio di seguito crea un file XLSX da zero e aggiunge un commento con un’immagine di sfondo alla cella A1.
Dopo aver eseguito il codice, A1 ha un commento con un’immagine di sfondo.
**Il file di output
Codice di esempio
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(AddPicturetoExcelComment.class) + "articles/"; | |
// Instantiate a Workbook | |
Workbook workbook = new Workbook(); | |
// Get a reference of comments collection with the first sheet | |
CommentCollection comments = workbook.getWorksheets().get(0).getComments(); | |
// Add a comment to cell A1 | |
int commentIndex = comments.add(0, 0); | |
Comment comment = comments.get(commentIndex); | |
comment.setNote("First note."); | |
comment.getFont().setName("Times New Roman"); | |
// Load/Read an image into stream | |
String logo_url = dataDir + "school.jpg"; | |
// Creating the instance of the FileInputStream object to open the logo/picture in the stream | |
FileInputStream inFile = new FileInputStream(logo_url); | |
// Setting the logo/picture | |
byte[] picData = new byte[inFile.available()]; | |
inFile.read(picData); | |
// Set image data to the shape associated with the comment | |
comment.getCommentShape().getFill().setImageData(picData); | |
// Save the workbook | |
workbook.save(dataDir + "APToExcelComment_out.xlsx"); |