C# Code to launch excel and open the associated spreadsheet (not looking to modify)

C#

I need a line of code to open an excel spreadsheet - not access\modify but physically launch excel as if I had double clicked on the spreadsheet itself.

As in OPEN C:\MYSHEET.XLS and have it launch excel and display the sheet . I am not looking to do COM or ODBC connections or anything.

THANKS!
Karl66Asked:
Who is Participating?
 
badbearontourConnect With a Mentor Commented:
Hi there

the quick and dirty way is to use this

System.Diagnostics.Process.Start(@"C:\MYSHEET.XLS");

this will work with any file that is associated with the Excel Program

BB
0
 
Karl66Author Commented:
Works great - does it only work with excel?
0
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
It will work with any extension that is REGISTERED on the system.  Process.Start() launches the associated executable and passes the filename as a command line parameter...
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
So, by default, for example...

    .txt --> NotePad
    .doc --> MSWord
    .xls --> MSExcel

etc...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.