[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2086
  • Last Modified:

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!
0
Karl66
Asked:
Karl66
  • 2
2 Solutions
 
badbearontourCommented:
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 TomlinsonMiddle 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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now