using System;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
namespace TestPr
{
public partial class Form1 : Form
{
Excel.Application application;
Excel.Workbook workbook;
Excel.Worksheet worksheet;
public Form1()
{
InitializeComponent();
application = new Excel.Application();
workbook = application.Workbooks.Open("C:\\Users\\artem\\OneDrive\\Рабочий стол\\CSProjects\\TestPr\\TestPr\\File\\TestExcelFile.xlsx");
worksheet = workbook.Worksheets[1];
}
private void button1_Click(object sender, EventArgs e)
{
worksheet.Cells[1, 1].Value2 = textBox1.Text;
workbook.Save();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
workbook.Close();
application.Quit();
}
}
}