Accessing Excel file from Sharepoint with R

I use

read_excel('//companySharepointSite/project/.../ExcelFilename.xlsx', 'Sheet1', skip=1)

Note, no https:, and sometimes I have to open the file first (i.e., cut and paste //companySharepointSite/project/.../ExcelFilename.xlsx into my browser's address bar)

I found that other answers did not work for me, perhaps because I am on a Mac, which obviously does not play as well with Microsoft products such as Sharepoint.

Ended up having to split it into two pieces: first download the Excel file to disk and then separately read that Excel file.


# the URL of your sharepoint file
file_url <- "https://yoursharepointsite/Documents/yourfile.xlsx"

# save the excel file to disk
    authenticate(active_directory_username, active_directory_password, "ntlm"),
    write_disk("tempfile.xlsx", overwrite = TRUE))

# save to dataframe
df <- read_excel("tempfile.xlsx")

# remove excel file from disk

This gets the job done, though would be interested if anyone knows how to avoid the interim step of writing to disk.

N.B. Depending on your specific machine/network/Sharepoint configuration, you may also be able to just use authenticate(":",":","ntlm") per this answer.