Click here to Skip to main content
12,749,754 members (37,456 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0
public void btnBrowse_Click(object sender, EventArgs e)
            string ExcelFile;
            int TotalSheets;
            Excel.Application Exapp;
            Microsoft.Office.Interop.Excel.Workbook Myworkbook;
            txtFile.Text = "";
                OpenFileDialog1.Filter = "Excel Files (*.xls)|*.xls|All Files(*.*)|*.*";
                OpenFileDialog1.InitialDirectory = @"c:\";
                OpenFileDialog1.FileName = "Select File";
                OpenFileDialog1.Title = "Select excel file..";
                ExcelFile = OpenFileDialog1.FileName; ;
                txtFile.Text = ExcelFile;
                Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
                Microsoft.Office.Interop.Excel.Workbook workbook = Exapp.Workbooks.Open(ExcelFile, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                TotalSheets = Myworkbook.Worksheets.Count;
                foreach (Excel.Worksheet wksh in Myworkbook.Worksheets)
                Myworkbook.Close(false, false, false);
            catch (Exception ex)
Posted 26-Jun-12 22:31pm
Updated 26-Jun-12 22:49pm
Sandeep Mewara 27-Jun-12 3:49am
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.
ryanb31 27-Jun-12 8:24am
What is the question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100