Excel Yorumuna Resim Ekleme

Microsoft Excel ile Excel Yorumuna resim ekleme

Microsoft Excel 2007 ile, bir hücre yorumuna arka plan olarak bir görüntüye sahip olmak mümkündür. Excel 2007’de bu şu şekilde gerçekleştirilir (yorumun zaten eklenmiş olduğu varsayılarak):

  1. Açıklamayı içeren hücreye sağ tıklayın.
  2. SeçmekYorumları Göster/Gizle ve yorumdaki tüm metni temizleyin.
  3. Seçmek için yorumun kenarlığına tıklayın.
  4. SeçmekBiçim , o zamanlarYorum Yap.
  5. Renkler ve Çizgiler sekmesinde,Renk.
  6. TıklamakDolgu Efektleri.
  7. Resim sekmesinde,Resim Seç.
  8. Resmi bulun ve seçin
  9. TıklamakTamam.

Aspose.Cells ile Excel Yorumuna resim ekleyin

Aspose.Cells bu değerli özelliği sağlar.

Aşağıdaki örnek kod, sıfırdan bir XLSX dosyası oluşturur ve A1 hücresine resim arka planıyla bir yorum ekler.

Kodu çalıştırdıktan sonra A1, arka plan resmi olan bir yoruma sahip olur.

çıktı dosyası

yapılacaklar:resim_alternatif_metin

Basit kod

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