Yorum Metin Rengini Nasıl Değiştirilir
Contents
[
Hide
]
Microsoft Excel, kullanıcılara ek bilgi eklemek ve verileri vurgulamak için hücrelere yorum eklemelerine izin verir. Geliştiriciler, yorumu özelleştirmek, hizalama ayarlarını belirtmek, metin yönü Font Rengi gibi işlemler yapmak isteyebilirler. Aspose.Cells, görevi başarmak için API’lar sağlar.
Aspose.Cells, bir yoruma yazı tipi rengi belirlemek için Shape.TextBody özelliği sağlar. Aşağıdaki örnek kod, bir yoruma metin yönü belirlemek için Shape.TextBody özelliğinin kullanımını göstermektedir.
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 | |
String dataDir = ""; | |
// Instantiate a new Workbook | |
Workbook workbook = new Workbook(); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Add some text in cell A1 | |
worksheet.getCells().get("A1").putValue("Here"); | |
// Add a comment to A1 cell | |
Comment comment = worksheet.getComments().get(worksheet.getComments().add("A1")); | |
// Set its vertical alignment setting | |
comment.getCommentShape().setTextVerticalAlignment(TextAlignmentType.CENTER); | |
// Set the Comment note | |
comment.setNote("This is my Comment Text. This is test"); | |
Shape shape = worksheet.getComments().get("A1").getCommentShape(); | |
shape.getFill().getSolidFill().setColor(Color.getBlack()); | |
Font font = shape.getFont(); | |
font.setColor(Color.getWhite()); | |
StyleFlag styleFlag = new StyleFlag(); | |
styleFlag.setFontColor(true); | |
shape.getTextBody().format(0, shape.getText().length(), font, styleFlag); | |
// Save the Excel file | |
workbook.save(dataDir + "outputChangeCommentFontColor.xlsx"); |
Yukarıdaki kodun çalıştırılmasıyla elde edilen çıktı dosyası referansınız için eklenmiştir.