×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need to download Excel file from Sharepoint

Need to download Excel file from Sharepoint

Need to download Excel file from Sharepoint

(OP)
I'm working on a Python (3.7) script to download an Excel (XLSX) file from within Sharepoint.

I've tried using the 'requests' module, as well as the 'Office365-REST-Python-Client' module, without success. I'm unable to open the downloaded file using Excel, the error message indicates that the file extension or the file format is invalid.

When I change the file extension to 'XLS', I see the error message '403 FORBIDDEN' within the file created by the 'requests' module. (It seems like what was actually downloaded was an error page.)

And I see the error message 'A potentially dangerous Request.Path value was detected from the client (?).' within the file created by the 'Office365-REST-Python-Client' module.

It seems the problem is that the URL for the spreadsheet I'm trying to download contains a question mark (due to there being query parameters):

...doc.aspx?sourcedoc=...&file=...&action=default

RE: Need to download Excel file from Sharepoint

(OP)
Turns out I needed to get the version of the SharePoint URL that specified a folder path to the file (a 'Shared_Documents' URL).

Once I got this, I was able to use the 'open_binary' method of the 'File' class to successfully download the Excel file from SharePoint.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close