using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
namespace WindowsFormsApplication1
{
public
partial class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void btnStart_Click(object
sender, EventArgs e)
{
Excel.Application
excel = new Excel.Application();
//создаем COM-объект Excel
Object
formula, result; //переменные для хранения формулы
и результата
formula=tbFormula.Text;
//берем формулу
result=excel._Evaluate(formula);
//вычисляем формулу
MessageBox.Show(result.ToString());
//выводим результат
excel.Quit();
//закрываем Excel
}
}
} |