日期:2014-05-17  浏览次数:20900 次

vs2010,office2007,C#,winform,在程序窗体中打开excel文件 [问题点数:100分]
就是在vs2010编写的winform程序打开电脑上的的excel文件,试过网上的几种办法都没成功,求大神帮忙实现,使用第三方开源控件也行,介绍下具体方法。用webbrowser那种就算啦。求大神帮忙!
C#编程 打开excel文件 vs2010 winform程序显示

------解决方案--------------------
楼主的意思是 把excel嵌到 winform内
------解决方案--------------------
微软的OWC组件你试过吗?
------解决方案--------------------
是webservice
http://www.cnblogs.com/denylau/archive/2010/07/23/1783530.html
------解决方案--------------------
我之前做过一个,这是代码希望能帮到你。要引用空间using Microsoft.Office.Interop.Excel;
这是代码
OpenFileDialog ofd = new OpenFileDialog();
            ofd.ShowDialog();
            ofd.Title = "打开Excel";
            ofd.Filter = "Excel文件(*.xls;*.xlsx)
------解决方案--------------------
*.xls;*.xlsx";
            ofd.ValidateNames = true;      
            ofd.CheckPathExists = true;    
            ofd.CheckFileExists = true;   
            ofd.RestoreDirectory = true;   
            string str = @"" + ofd.FileName;   
            if (!string.IsNullOrEmpty(str))
            {
                try
                {
                    string strOdbcCon = "Provider=Microsoft.ACE.OleDb.12.0;" + "Data Source=" + str + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";//设置Excel文件位置
                    OleDbConnection OleDB = new OleDbConnection(strOdbcCon);
                    OleDbDataAd