EXCEL Read Comment in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source
 

The sample demonstrates how to read comment from an excel workbook.

ReadComment.gif

		private void btnRun_Click(object sender, System.EventArgs e)
		{
			Workbook workbook = new Workbook();
			
			workbook.LoadFromFile(@"..\..\..\..\..\..\Data\CommentSample.xls");
			//Initialize worksheet
			Worksheet sheet = workbook.Worksheets[0];

			textBox1.Text = sheet.Range["A1"].Comment.Text;
			richTextBox1.Rtf = sheet.Range["A2"].Comment.RichText.RtfText;
		}

		Private Sub btnRun_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRun.Click
			Dim workbook As Workbook = New Workbook()

			workbook.LoadFromFile("..\..\..\..\..\..\Data\CommentSample.xls")
			'Initialize worksheet
			Dim sheet As Worksheet = workbook.Worksheets(0)

			textBox1.Text = sheet.Range("A1").Comment.Text
			richTextBox1.Rtf = sheet.Range("A2").Comment.RichText.RtfText
		End Sub