Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
http://reference.wolfram.com/mathematica/ref/format/XLS.html


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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.