Hello MSDN. I am new to C#.NET development and I am trying to figure out how to write data into specific sheets and cells in a workbook that is already opened by opefiledialog method.
Is there a way to do this?
Here is the code.
private void selectHeatBalanceToolStripMenuItem_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "xls files (*.xls)|*.xls|xlsx files (*.xlsx)|*.xlsx";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
Workbook wbook;
Worksheet wsheet;
_Application excel = new _Excel.Application();
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
excel = new _Excel.Application();
wbook = excel.Workbooks.Open(openFileDialog.FileName);
excel.Visible = true;
}
}
}