vb.net 如何在VB中用Excel打开一个xls文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14497006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 16:36:52  来源:igfitidea点击:

How to open a xls file with Excel in VB

vb.netexcel

提问by Shane Hsu

So, how can I tell the system to open the file for me? I've tried

那么,我如何告诉系统为我打开文件?我试过了

Shell(ExcelFilePath)

But an exception was thrown although the file path is from OpenFileDialog.FileOk

但是尽管文件路径来自 OpenFileDialog.FileOk 还是抛出了异常

So, I am trying to play with Excel.Application, is it possible to open the file with that?

所以,我正在尝试使用 Excel.Application,是否可以用它打开文件?

回答by SysDragon

This will open the file with Excel:

这将使用 Excel 打开文件:

Process.Start("EXCEL.EXE", """C:\Folder\file.xls""")

Being the second string the arguments for the process. See the MSDN Dcoumentation.

作为第二个字符串的过程的参数。请参阅MSDN 文档

回答by Arpit

try this

尝试这个

System.Diagnostics.Process.Start("FilePath")

it will open the file in an application associated with it.

它将在与其关联的应用程序中打开该文件。