简体   繁体   中英

Exporting Python Data to Excel File on Sharepoint

I have a dataframe that I want to export to an existing Excel file that exists online on my company's sharepoint. I have the following line of code to do this:

df.to_excel(r'Path where the exported excel file will be stored\File Name.xlsx', sheet_name='Your sheet name', index = False) The filepath starts with https and ends with a filetype.xlsx?web=1

Python of course doesn't recognise.xlsx?web=1 as a valid filetype so do I just ignore the?web=1 at the end? This is what I did but get an access denied error. What do I need to do to be able to export to this file?

Edit: Filepath is https://companyname.sharepoint.com/sites/XXX/Shared%20Documents/07%20-%20LE%20(Loss%20Elimination)/02%20-%20Open%20(Current)%20Loss%20Elimantions/13%20-%20Material%20loss%20against%20BOM/Copy_Material%20Flow%20for%20HDW%20Euro%20When%20to%20FP.xlsx?web=1

The filepath starts with https and ends with a filetype .xlsx?web=1

That's not a path, that's a URL. You cannot simply "save" to a URL.

There are Python libraries for working with sharepoint. For example Office365-REST-Python-Client , pysharepoint and this one on pypi , but the latter only seems to support downloading , not uploading.

Since pysharepoint is basically a front-end for SharePlum , you might want to look at that as well. It comes with documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM