# \donttest{
if (requireNamespace("openxlsx2", quietly = TRUE)) {
# Roundtrip: export with labels, read back with reconstruction
tmp <- tempfile(fileext = ".xlsx")
write_xlsx(survey_data, tmp)
data <- read_xlsx(tmp)
attr(data$gender, "labels") # Value labels restored
attr(data$gender, "label") # Variable label restored
# Skip label reconstruction
raw <- read_xlsx(tmp, labels = FALSE)
unlink(tmp)
}
# }
Run the code above in your browser using DataLab