How to open a file in Excel from the command line

Is it possible to tell Excel to open a file from the command line?

In Linux, I could do this using the command

libreoffice --calc test.xlsx

Solution 1:

You can use the open command:

This will use the default application for the file type, which may not be the desired application.

open test.xlsx

or, to specify the application explicitly:

open test.xlsx -a /Applications/Microsoft\ Office\ 2011/Microsoft\ Excel.app/

or even,

open test.xlsx -a "Microsoft Excel"

A really useful way of doing this is to make an alias to Excel (in your .bash_profile)

alias xl='open -a "Microsoft Excel"'

Then you can just type the following to open an file in Excel:

xl file.csv