Skip to content

Commit

Permalink
Reorder tags and reorganize xl_open and write_xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jul 11, 2023
1 parent 988f1f7 commit 51dcf2a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
41 changes: 22 additions & 19 deletions R/write_xlsx.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
#' @name write_xlsx
#' @title write data to an xlsx file
#' @description write a data.frame or list of data.frames to an xlsx file
#' @param x object or a list of objects that can be handled by [write_data()] to write to file
#' @param file xlsx file name
#' @param as_table write using write_datatable as opposed to write_data
#' @param ... optional parameters to pass to functions:
#' \itemize{
#' \item{[wb_workbook()]}
#' \item{[wb_add_worksheet()]}
#' \item{[wb_add_data()]}
#' \item{[wb_freeze_pane]}
#' \item{[wb_save()]}
#' }
# `write_xlsx()` ---------------------------------------------------------------
#' Write data to an xlsx file
#'
#' see details.
#' @details Optional parameters are:
#' Write a data.frame or list of data.frames to an xlsx file
#'
#' @seealso [wb_add_worksheet()], [write_data()]
#' @details
#' Optional parameters are:
#'
#' **wb_workbook Parameters**
#' \itemize{
Expand Down Expand Up @@ -61,10 +52,23 @@
#'
#' columns of x with class Date or POSIXt are automatically
#' styled as dates and datetimes respectively.
#' @seealso [wb_add_worksheet()], [write_data()]
#'
#' @param x object or a list of objects that can be handled by [write_data()] to write to file
#' @param file xlsx file name
#' @param as_table write using write_datatable as opposed to write_data
#' @param ... optional parameters to pass to functions:
#' \itemize{
#' \item{[wb_workbook()]}
#' \item{[wb_add_worksheet()]}
#' \item{[wb_add_data()]}
#' \item{[wb_freeze_pane]}
#' \item{[wb_save()]}
#' }
#'
#' see details.
#'
#' @return A workbook object
#' @examples
#'
#' ## write to working directory
#' write_xlsx(iris, file = temp_xlsx(), colNames = TRUE)
#'
Expand All @@ -87,7 +91,6 @@
#' write_xlsx(l, temp_xlsx(), colWidths = 20)
#' write_xlsx(l, temp_xlsx(), colWidths = list(100, 200, 300))
#' write_xlsx(l, temp_xlsx(), colWidths = list(rep(10, 5), rep(8, 11), rep(5, 5)))
#'
#' @export
write_xlsx <- function(x, file, as_table = FALSE, ...) {

Expand Down
27 changes: 14 additions & 13 deletions R/xl_open.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#' Open a Microsoft Excel file (xls/xlsx) or an openxlsx2 wbWorkbook
#'
#' @description This function tries to open a Microsoft Excel (xls/xlsx) file or
#' an openxlsx2 wbWorkbook with the proper application, in a portable manner.
#' @description
#' This function tries to open a Microsoft Excel (xls/xlsx) file or,
#' an openxlsx2 wbWorkbook with the proper application, in a portable manner.
#'
#' In Windows it uses `base::shell.exec()` (Windows only function) to
#' determine the appropriate program.
#' On Windows it uses `base::shell.exec()` (Windows only function) to
#' determine the appropriate program.
#'
#' In Mac (c) it uses system default handlers, given the file type.
#' In Mac (c) it uses system default handlers, given the file type.
#'
#' In Linux it searches (via `which`) for available xls/xlsx reader
#' applications (unless `options('openxlsx2.excelApp')` is set to the app bin
#' path), and if it finds anything, sets `options('openxlsx2.excelApp')` to the
#' program chosen by the user via a menu (if many are present, otherwise it
#' will set the only available). Currently searched for apps are
#' Libreoffice/Openoffice (`soffice` bin), Gnumeric (`gnumeric`) and Calligra
#' Sheets (`calligrasheets`).
#' In Linux it searches (via `which`) for available xls/xlsx reader
#' applications (unless `options('openxlsx2.excelApp')` is set to the app bin
#' path), and if it finds anything, sets `options('openxlsx2.excelApp')` to the
#' program chosen by the user via a menu (if many are present, otherwise it
#' will set the only available). Currently searched for apps are
#' Libreoffice/Openoffice (`soffice` bin), Gnumeric (`gnumeric`) and Calligra
#' Sheets (`calligrasheets`).
#'
#' @param x A path to the Excel (xls/xlsx) file or Workbook object.
#' @param interactive If `FALSE` will throw a warning and not open the path.
#' This can be manually set to `TRUE`, otherwise when `NA` (default) uses the
#' value returned from [base::interactive()]
#' @export
#' @examples
#' \donttest{
#' if (interactive()) {
Expand All @@ -35,6 +35,7 @@
#' xl_open(wb)
#' }
#' }
#' @export
xl_open <- function(x, interactive = NA) {
UseMethod("xl_open")
}
Expand Down
6 changes: 2 additions & 4 deletions man/write_xlsx.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/xl_open.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51dcf2a

Please sign in to comment.