diff --git a/DESCRIPTION b/DESCRIPTION index 6106542..9fdeeff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: flipAPI Type: Package Title: Web APIs tools -Version: 1.3.2 +Version: 1.3.3 Author: Displayr Maintainer: Displayr Description: Functions to extract data and interact with web APIs. diff --git a/R/DataMart.R b/R/DataMart.R index 5045856..caad37d 100644 --- a/R/DataMart.R +++ b/R/DataMart.R @@ -258,6 +258,9 @@ QLoadData <- function(filename, company.token = NA, ...) #' #' Saving to .gif file is only supported for \code{"gganim"} objects created using #' \code{gganimate}. +#' +#' When saving to .xlsx file, \code{object} is first coerced to a data.frame using +#' \code{\link{as.data.frame}}. #' @export QSaveData <- function(object, filename, ...) { @@ -278,7 +281,7 @@ QSaveData <- function(object, filename, ...) stop("To save as a Powerpoint pptx file, the input must be created with ", "officer::read_pptx()") else if (type == "xlsx") - openxlsx::write.xlsx(object, tmpfile, ...) + openxlsx::write.xlsx(as.data.frame(object, check.names = FALSE), tmpfile, ...) else if (type == "gif" && inherits(object, c("gganim", "gif_image"))) anim_save(tmpfile, object, ...) else if (type == "gif") @@ -311,10 +314,11 @@ QSaveData <- function(object, filename, ...) paste0(" > QLoadData('", filename, "')"), sep = "\n") else - msg <- paste0("Object uploaded to Displayr Cloud Drive. To re-import select ", - "Image > Displayr Cloud Drive.") + msg <- paste0("Object uploaded to Displayr Cloud Drive. To re-import select:\n ", + " Image > Displayr Cloud Drive\n", + "then select ", sQuote(filename), " from the dropdown menu.") message(msg) - invisible() + invisible(msg) } qSaveImage <- function(filename) diff --git a/man/QSaveData.Rd b/man/QSaveData.Rd index 58e36b7..4ce46b8 100644 --- a/man/QSaveData.Rd +++ b/man/QSaveData.Rd @@ -28,4 +28,7 @@ the \code{officer} package. Saving to .gif file is only supported for \code{"gganim"} objects created using \code{gganimate}. + +When saving to .xlsx file, \code{object} is first coerced to a data.frame using +\code{\link{as.data.frame}}. } diff --git a/tests/testthat/test-datamart.R b/tests/testthat/test-datamart.R index 4b814dc..e955e15 100644 --- a/tests/testthat/test-datamart.R +++ b/tests/testthat/test-datamart.R @@ -22,7 +22,7 @@ test_that("SaveData/LoadData", { # XLSX expect_invisible(QSaveData(mtcars, "mtcars.xlsx")) expect_true(QFileExists("mtcars.xlsx")) - expect_error(QLoadData("mtcars.xlsx"), NA) + expect_equal(dim(QLoadData("mtcars.xlsx")), dim(mtcars)) # GIF library(gganimate)