首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用Python3 Sharepy从共享的0365商业sharepoint下载excel文件会导致文件损坏

使用Python3 Sharepy从共享的0365商业sharepoint下载excel文件会导致文件损坏
EN

Stack Overflow用户
提问于 2019-06-07 20:06:45
回答 1查看 2.3K关注 0票数 1

与之前没有完全回答的问题类似,我正在尝试使用Python3和Sharepy下载一个here文件,使用pandas对其进行操作,然后将其重新上传回sharepoint。

问题可能是,我不知道真正的excel文件存储在哪里,我只有一个引用链接,可以分享给其他有访问权限的人。下载该链接是指向Excel Online的html,而不是我想要的Excel文件。有什么建议吗?

代码语言:javascript
复制
import sharepy
from sharepy import connect
from sharepy import SharePointSession

server='https://mycompany365.sharepoint.com'
user='first.m.last@mycompany.com'
password='1234Password1234'

# Copy/Paste file link from sharepoint below. #<--- partially works
site = "https://mycompany.sharepoint.com/:x:/r/sites/Sales/Shared%20Documents/General/My_File.xlsx?d=wb182f80code74bd586b225codebeb1c&csf=1&e=CodeeT"

s = sharepy.connect(server,user,password)

#  Download file to same folder as python script, save as My_File.xlsx.
r = s.getfile(site,\
 filename = 'My_File.xlsx')

print("Script Complete")

My site =会导致html指向正确的联机文件,而不是真正的Excel文件。我怎样才能找到真正的文件呢?

EN

回答 1

Stack Overflow用户

发布于 2019-06-10 01:14:23

在使用了一些暴力手段之后,我发现删除“分享链接”末尾的随机代码会打开原始文件:

代码语言:javascript
复制
# Copy/Paste file link from sharepoint below. Before...
site = "https://mycompany.sharepoint.com/:x:/r/sites/Sales/Shared%20Documents/General/My_File.xlsx?d=wb182f80code74bd586b225codebeb1c&csf=1&e=CodeeT"

# Copy/Paste file link from sharepoint below. After.
site = "https://mycompany.sharepoint.com/:x:/r/sites/Sales/Shared%20Documents/General/My_File.xlsx"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56494016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档