I have excel saved in sharepoint and I am trying to read it with openpyxl. I have URL path to excel which is below and I have different options I see on internet and none of them worked.
How can I read excel in below path using openpyxl?
Below is the code I have and I getting HTTP forbidden error
from openpyxl import load_workbook
from io import BytesIO
import urllib
URL = https://company.sharepoint.com/:x:/r/sites/global/tasks/ADT/_layouts/15/Doc.aspx?
sourcedoc=%7BBFD411FA-303E-4950-961C-
6702D81E112B%7D&file=SEPT%20ALL%20ROB.xlsx&action=default&mobileredirect=true
def load_workbook_from_url(URL):
file = urllib.request.urlopen(URL).read()
return load_workbook(filename=BytesIO(file))
wb = load_workbook_from_url(URL)
sheetlist = wb.get_sheet_names()
print(sheetlist)
Error I get is : raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden
URL = r"https://path/to/your/file.xlsx". Other than that, i do not know if you can access files on a sharepoint publicly like that, i would need an example, accessible file to investigate further.