Bir Çalışma Sayfasına Cell Yorum Ekleme ve Kaldırma

Yorum Ekleme ve Kaldırma Cells

Hücrelere yorum eklemek için:

  1. Mevcut bir Excel dosyasını açın.
  2. Bir hücreye yorum ekleyin.
  3. Dosya ‘yı kaydet.

Yorumları kaldırmak için, yorumun kaldırılması dışında süreç benzerdir.

Aşağıdaki kod örnekleri, öncelikle nasıl yapılacağını gösterir.yorum ekle ve sonra nasılbir yorumu kaldır VSTO veya Aspose.Cells for .NET ile.

Yorum ekleme

Bu kod parçacıkları, önce bir hücreye nasıl yorum ekleneceğini gösterir.VSTO (C#, VB) ve ardındanAspose.Cells for .NET (C#, VB).

VSTO ile Yorum Ekleme

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 ile Yorum Ekleme

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

Yorumları Kaldırma

Bir hücreden yorumu kaldırmak için aşağıdaki kod satırlarını kullanın.VSTO (C#, VB) veAspose.Cells for .NET (C#, VB).

VSTO ile Yorum Kaldırma

C#

 //Remove the comment.

rng1.Comment.Delete();    

Aspose.Cells for .NET İle Yorum Kaldırma

C#

 //Remove the comment.

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