3
$\begingroup$

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?

$\endgroup$
2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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