0

i'm trying to import .xls file to Sharepoint Team Site (Pattern : https://azureABC.sharepoint.com/teams/ABCgroup/Shared%20Documents/Forms/AllItems.aspx) using this function that i used for regular sharepoint Site :

def UploadLocalFileToSharepointSite(username, password, site_name, base_path, doc_library ,file_name) :
    authcookie = Office365(base_path, username=username, password=password).GetCookies()
    full_path = base_path+'/sites/'+site_name
    site = Site(full_path, version=Version.v2016, authcookie=authcookie)
    folder = site.Folder(doc_library)
    folder.upload_file('Upload New file', file_name)

But it's not working. enter image description here Have you any suggestions?

  • what's the error msg? `folder.upload_file('Upload New file', file_name)` seems can only upload txt file. if you want to upload .xls file, you should upload its binary content. `with open(filepath, 'rb+') as file_input: try: folder.upload_file(file_input, filename) except Exception as err: print("Some error occurred: " + str(err))` – Baker_Kong Dec 02 '20 at 01:33
  • I tried with .txt file and got the same error. You can see it now. – Maher Kebaier Dec 02 '20 at 13:09
  • Did you ever figure this out? Having the same issue. – smitty_werben_jagerm Dec 21 '21 at 19:45

0 Answers0