I am having a hard time figuring this out. I would like to do on button click event to open a filedialog window in which the user will select an excel file and the file will get open in excel.
I have created the filebox and I am able to get the excel to open a new file,but I can't figure out how to get the two to mesh.
what I am trying to use is as follows,
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
private void button1_Click(object sender, EventArgs e)
{
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.StreamReader sr = new
System.IO.StreamReader(openFileDialog1.FileName);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
}
}
}
and I was going to use this to open excel
Excel.Application excel = new Excel.Application();
Excel.Workbook wb = excel.Workbooks.Open(filename);