إدخال وإزالة Cell تعليقات في ورقة عمل

إضافة وإزالة التعليقات على Cells

لإضافة تعليقات إلى الخلايا:

  1. افتح ملف Excel موجود.
  2. أضف تعليقًا إلى خلية.
  3. حفظ الملف.

لإزالة التعليقات ، تكون العملية مماثلة ، باستثناء إزالة التعليق.

توضح نماذج الكود أدناه أولاً كيفية القيام بذلكاضف تعليق ثم كيفإزالة تعليق مع VSTO أو Aspose.Cells for .NET.

ادراج التعليقات

توضح مقتطفات التعليمات البرمجية هذه كيفية إضافة تعليق إلى خلية أولاً باستخدامVSTO (C#، VB) ثم معAspose.Cells for .NET (C# ، VB).

إدخال تعليق بواسطة VSTO

C#

 .......

using Microsoft.VisualStudio.Tools.Applications.Runtime;

using Excel = Microsoft.Office.Interop.Excel;

using Office = Microsoft.Office.Core;

using System.Reflection;

.......

//Instantiate the Application object.

Excel.Application excelApp = new Excel.ApplicationClass();

//Specify the template excel file path.

string myPath=@"d:\test\Book1.xls";

//Open the excel file.

excelApp.Workbooks.Open(myPath, Missing.Value, Missing.Value,

Missing.Value, Missing.Value,

Missing.Value, Missing.Value,

Missing.Value, Missing.Value,

Missing.Value, Missing.Value,

Missing.Value, Missing.Value,

Missing.Value, Missing.Value);

//Get the A1 cell.

Excel.Range rng1=excelApp.get_Range("A1", Missing.Value);

//Add the comment with text.

rng1.AddComment("This is my comment");

//Save the file.

excelApp.ActiveWorkbook.Save();

//Quit the Application.

excelApp.Quit();

ادراج تعليق مع Aspose.Cells for .NET

C#

 .......

using Aspose.Cells;

.......

//Specify the template excel file path.

string myPath=@"d:\test\Book1.xls";

//Instantiate a new Workbook.

//Open the excel file.

Workbook workbook = new Workbook(myPath);

//Add a Comment to A1 cell.

int commentIndex=workbook.Worksheets[0].Comments.Add("A1");

//Accessing the newly added comment

Comment comment=workbook.Worksheets[0].Comments[commentIndex];

//Setting the comment note

comment.Note="This is my comment";

//Save As the excel file.

workbook.Save(@"d:\test\Book1.xls");

إزالة التعليقات

لإزالة تعليق من خلية ، استخدم أسطر التعليمات البرمجية التالية لـVSTO (C# ، VB) وAspose.Cells for .NET (C# ، VB).

إزالة تعليق باستخدام VSTO

C#

 //Remove the comment.

rng1.Comment.Delete();    

إزالة تعليق بالرقم Aspose.Cells for .NET

C#

 //Remove the comment.

workbook.Worksheets[0].Comments.RemoveAt("A1");