% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/google_sheets.R
\name{export_google_sheet}
\alias{export_google_sheet}
\title{Export a survey instrument to Google Sheets collection format}
\usage{
export_google_sheet(instrument, sheet_url, output_dir = ".")
}
\arguments{
\item{instrument}{An \code{sframe} object.}

\item{sheet_url}{Character. The URL of an existing Google Sheet. The sheet
must be shared so that anyone with the link can edit, or use service
account credentials via \code{googlesheets4}.}

\item{output_dir}{Character. Directory to write the Apps Script file.
Defaults to the current working directory.}
}
\value{
The path to the generated \code{.gs} Apps Script file, invisibly.
}
\description{
Generates a Google Apps Script file that, when run in a Google Sheet,
creates a response collection endpoint for a survey instrument. The builder
can store the deployed Apps Script URL in survey metadata, and the same
sheet can be read back with \code{\link[=read_sheet_responses]{read_sheet_responses()}}.
}
\examples{
instr <- read_sframe(
  system.file("extdata", "tourism_services_demo.sframe",
              package = "surveyframe")
)
script <- export_google_sheet(
  instr,
  sheet_url = "https://docs.google.com/spreadsheets/d/demo",
  output_dir = tempdir()
)
file.exists(script)
}
\seealso{
\code{\link[=read_sheet_responses]{read_sheet_responses()}}, \code{\link[=read_responses]{read_responses()}}, \code{\link[=write_sframe]{write_sframe()}}
}
