2

I am needing to instantiate a File object containing the contents of an excel spreadsheet that is stored on the SharePoint site. It is contained within SitePages/data/TestRoles.xlsx, so I figured the path I should pass it is "data/TestRoles.xlsx". My code to create the file is then:

var f = new File([""], "data/TestRoles.xlsx");

But that ended up note working and I'm not sure why, I get a "Unsupported file NaN" error. What is the correct way to instantiate a File object with a file stored on my SharePoint site? Thanks in advance.

  • I ended up creating a script to convert my .xlsx to a .txt in csv form and then upload it to sharepoint, retrieve it with an XMLHttpRequest. Works just fine. If anyone thinks this is a bad way to solve this let me know, and feel free to answer the original question. – YungGun Feb 13 '17 at 20:48
1

You could use a library like ExcelPlus (that I have created) to help you reading your Excel file.

With ExcelPlus you have an example:

var ep=new ExcelPlus();
// we call openRemote()
ep.openRemote("/path/tp/your/file.xlsx", function(passed) {
  if (!passed) alert("Error: impossible to load the remote file");
  else console.log(ep.selectSheet(1).readAll()) // show the content of the first sheet
})

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.