如何使用c#打开excel文档 [英] How to open an excel document using c#
本文介绍了如何使用c#打开excel文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了 Open XML SDK 2.0 来创建新的电子表格并保存到用户文件夹。我想要保存后自动打开这个。该文件是xlsx格式。
I've used the Open XML SDK 2.0 to create a new spreadhsheet and save to a users folder. i want to be able to open this automatically after saving. The file is in the xlsx format.
我试过
SpreadsheetDocument.Open(fileName, true);
这根本不工作。我希望代码能够以任何版本的excel(2003,2007和2010)打开文件(假设:2003将安装兼容性包)
This isn't working at all. I'd like the code to open the file in whatever version of excel the user has - 2003, 2007 and 2010 (Assumption: 2003 will have the compatibility pack installed)
推荐答案
如果将excel设置为系统上xls文件的默认查看器,则可以使用进程类:
If excel is set as the default viewer for xls files on the system you can open the file using Process class:
System.Diagnostics.Process.Start("myFile.xls");
这篇关于如何使用c#打开excel文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文