Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can import an Excel file into Mathematica easily:

enter image description here

But when I try from .Net it fails:

enter image description here

These are the commands and errors I am getting:

xlData = Import[\"C://Users//138013//Desktop//RefinedDataset.xlsx\", {\"Sheets\", \"MySheet\"}]

"Import::chtype: \r\n First argument C://Users//138013//Desktop//RefinedDataset.xlsx\r\n is not a valid file, directory, or URL specification."

xlData = Import[\"//Desktop//RefinedDataset.xlsx\", {\"Sheets\", \"MySheet\"}]

"Import::nffil: File not found during Import."

I've done research and seen these articles but nothing shed light on why its an invalid file:
Importing from Excel
Open Excel file with Mathematica

Does someone know why Import is giving me a is not a valid file when the same command works in Mathematica and the file does exist and is valid?

share|improve this question
up vote 2 down vote accepted

Answering my own question to help future .Net/Mathematica Developers. I've posted this answer as a Community Wiki, if anyone has a better/alternate solution please share.

This Q & A helped : How to set path of IMPORT from excel into Mathematica? but is specific to Mathematica - which works for me although same command via .NetLink fails.

It turns out in .Net you have to use 4 slashes:

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.