EXCEL Read Formulas in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source
 

The sample demonstrates how to read formulas from spreadsheet.

ReadFormulas.gif

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

			textBox1.Text = sheet.Range["C5"].Formula;
			textBox2.Text = sheet.Range["C5"].FormulaNumberValue.ToString();
		}

		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\ReadFormulasSmple.xls")
			Dim sheet As Worksheet = workbook.Worksheets(0)

			textBox1.Text = sheet.Range("C5").Formula
			textBox2.Text = sheet.Range("C5").FormulaNumberValue.ToString()
		End Sub