Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open an excel document using c#

Tags:

c#

excel

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.

I tried

 SpreadsheetDocument.Open(fileName, true);

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)

like image 885
littlechris Avatar asked Nov 30 '22 08:11

littlechris


1 Answers

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");
like image 62
Adrian Fâciu Avatar answered Dec 02 '22 21:12

Adrian Fâciu