Skip to content

Instantly share code, notes, and snippets.

@dickoa
Created April 6, 2022 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dickoa/fceb95c21b3a4ec2087070648ac65670 to your computer and use it in GitHub Desktop.
Save dickoa/fceb95c21b3a4ec2087070648ac65670 to your computer and use it in GitHub Desktop.
Download and read Excel sheets from R
library(Microsoft365R)
library(tidyverse)
library(readxl)
odb <- get_business_onedrive(app = "d44a05d5-c6a5-4bbb-82d2-443123722380")
### Check files
odb$list_items()
### Check files in "Documents"
odb$list_items("Documents")
### Download one excel file in the roots
odb$download_file("DemographicsTemplate_CHD.xlsx", dest = "~/test.xlsx")
f <- tempfile(fileext = ".xlsx")
odb$download_file("DemographicsTemplate_CHD.xlsx",
dest = f,
overwrite = TRUE)
df <- read_excel(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment