如何打开Excel文件 [英] how to open excel file

查看:80
本文介绍了如何打开Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在处理Excel工作表.我已经将数据从datagridview导出到excel表中.现在,我想单击按钮来查看此Excel工作表.我该怎么办.
预先感谢
neaS

hi all,
i am working on excel sheet. i had already export data from a datagridview into excel sheet. now i want to view this excel sheet on click of a button. how could i do that.
thanx in advance
neaS

推荐答案

早上好,

下面的链接显示了如何自动执行Excel ...
http://support.microsoft.com/kb/301982 [ http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx
Good morning,

The link below shows how to automate Excel...
http://support.microsoft.com/kb/301982[^]

If you''re looking to open a saved file, then try the following:

http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx


使用Process.Start(由Bert链接).确保将UseShellExecute设置为true,以便可以在.xls上使用Process.Start.这将启动您与.xls相关联的任何应用程序(可能是Excel,但可能不是),并将工作表加载到其中.
Use Process.Start (as linked by Bert). Make sure you set UseShellExecute to true so that you can use Process.Start on the .xls. This will start whatever application you have associated with .xls (probably Excel, but it might not be) and load the sheet into it.



假设您有一个Excel工作表,其中包含以下格式的数据


Hi,
suppose you have an excel sheet contains data in the following format


<br />
ID	ISBN	        Date<br />
1	0273600796	10/1/2011<br />
2	0071162070	10/1/2011<br />
3	0071162070	10/15/2011<br />
4	0070522235	10/15/2011<br />
5	0070527105	11/1/2011<br />
6	0070577277	11/1/2011<br />
7	007024801x	11/15/2011<br />
8	0071164278	12/1/2011<br />
9	0071140654	12/1/2011<br />




保存在名为"OutOfPrint.xls"的excel文件中
您可以使用以下代码片段将此文件读入datagridview






saved in excel file named "OutOfPrint.xls"
you can use the following code snip to read this file into datagridview



DbProviderFactory factory =
                DbProviderFactories.GetFactory("System.Data.OleDb");

                using (DbConnection connection = factory.CreateConnection())
                {
                    connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
                Data Source=OutOfPrint.xlsx;Extended Properties=
                ""Excel 8.0;HDR=YES;""";

                    using (DbCommand command = connection.CreateCommand())
                    {
                        command.CommandText = "SELECT ID,ISBN,Date FROM [OutofPrint


这篇关于如何打开Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆