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?


1 Answer 1


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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