Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Write to an already opened excel file (through openfiledialog)

$
0
0

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;
                }
            }

            
        }




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>