Create spreadsheets & documents with R
Create a shareable spreadsheet straight from R using httr — useful for turning analysis or model output into a link you can drop into a report or email. POST your data frame as rows and read the URL back. No Google Sheets auth required.
R (httr)
library(httr)
res <- POST(
"https://openofficeai.com/api/v1/sheets",
add_headers(Authorization = "Bearer YOUR_API_KEY"),
body = list(
title = "Q3 Revenue",
sheets = list(list(rows = list(
list("Month", "Revenue", "Growth"),
list("July", 48200, "+12%")
)))
),
encode = "json"
)
content(res)$urlHow to create a spreadsheet with R
- 1Install and load httr (or httr2).
- 2POST a list body with encode = "json" and the Authorization header.
- 3Read content(res)$url from the response.
- 4Convert a data frame to rows with apply(df, 1, as.list) before sending.
Why use OpenOfficeAI with R
- Share analysis output as a link, not an emailed .xlsx.
- Fits R Markdown, Shiny apps, and scheduled scripts.
- No googlesheets4 OAuth flow for the viewer.
Frequently asked questions
How do I turn a data frame into the rows format?
Build a header row from names(df), then append each row: c(list(as.list(names(df))), apply(df, 1, as.list)). Pass that as the rows value with encode = "json".
Can I use this from a Shiny app?
Yes. Call the API inside an observeEvent or a future/promise so the UI stays responsive, then render the returned url as a download/share link.
Does it work with httr2?
Yes. Use request(url) |> req_auth_bearer_token(key) |> req_body_json(list(...)) |> req_perform(), then resp_body_json()$url.
Start creating documents with R
Free tier includes 500 API calls per month — no card required.
Related integrations