Comment changer l arrière plan dans le commentaire dans Excel
Comment changer la couleur dans le commentaire dans Excel
Lorsque vous n’avez pas besoin de la couleur d’arrière-plan par défaut pour les commentaires, vous voudrez peut-être la remplacer par une couleur qui vous intéresse.Comment changer la couleur d’arrière-plan de la boîte de commentaires dans Excel?
Le code suivant vous guidera sur la façon d’utiliser Aspose.Cells pour ajouter votre couleur d’arrière-plan préférée aux commentaires de votre choix.
Nous avons préparé un fichier d’exemple pour vous.Ce fichier est utilisé pour initialiser l’objet Workbook dans le code ci-dessous.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string path = ""; | |
//Initialize a new workbook. | |
Workbook book = new Workbook(path + "exmaple.xlsx"); | |
// Accessing the newly added comment | |
Comment comment = book.Worksheets[0].Comments[0]; | |
// change background color | |
Shape shape = comment.CommentShape; | |
shape.Fill.SolidFill.Color = Color.Red; | |
// Save the Excel file | |
book.Save(path + "result.xlsx"); |
Exécutez le code ci-dessus et vous obtiendrez un fichier de sortie.
Comment insérer une image ou une photo dans le commentaire dans Excel
Microsoft Excel permet aux utilisateurs de personnaliser l’apparence des feuilles de calcul dans une large mesure. Il est même possible d’ajouter des images d’arrière-plan aux commentaires.Ajouter une image d’arrière-plan peut être un choix esthétique, ou être utilisé pour renforcer la marque.
Le code d’exemple ci-dessous crée un fichier XLSX à partir de zéro en utilisant Aspose.Cells API, et ajoute un commentaire avec une image d’arrière-plan à la cellule A1.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = ""; | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiate a Workbook | |
Workbook workbook = new Workbook(); | |
// Get a reference of comments collection with the first sheet | |
CommentCollection comments = workbook.Worksheets[0].Comments; | |
// Add a comment to cell A1 | |
int commentIndex = comments.Add(0, 0); | |
Comment comment = comments[commentIndex]; | |
comment.Note = "First note."; | |
comment.Font.Name = "Times New Roman"; | |
// Load an image into stream | |
Bitmap bmp = new Bitmap(dataDir + "image2.jpg"); | |
MemoryStream ms = new MemoryStream(); | |
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); | |
// Set image data to the shape associated with the comment | |
comment.CommentShape.Fill.ImageData = ms.ToArray(); | |
dataDir = dataDir + "commentwithpicture1.out.xlsx"; | |
// Save the workbook | |
workbook.Save(dataDir, Aspose.Cells.SaveFormat.Xlsx); |