-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate old functions write_*()
and remove_*()
#1064
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
622e3f9
Deprecate `remove_comment()` `write_comment()`, `write_formula()`, `w…
olivroy 0fd67b6
Update tests/testthat/test-wb_functions.R
olivroy 24385c0
Move functions to deprecate file.
olivroy 9456b44
Apply suggestions from code review
olivroy 0563490
Merge branch 'main' into deprecate
olivroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
#' Internal comment functions | ||
#' | ||
#' Users are advised to use [wb_add_comment()] and [wb_remove_comment()]. | ||
#' `write_comment()` and `remove_comment()` are now deprecated. openxlsx2 will stop | ||
#' exporting it at some point in the future. Use the replacement functions. | ||
#' @name comment_internal | ||
NULL | ||
|
||
#' @rdname comment_internal | ||
#' @inheritParams wb_add_comment | ||
#' @param comment An object created by [create_comment()] | ||
#' @param row,col Row and column of the cell | ||
#' @param color optional background color | ||
#' @param file optional background image (file extension must be png or jpeg) | ||
#' @keywords internal | ||
#' @export | ||
#' @inherit wb_add_comment examples | ||
write_comment <- function( | ||
wb, | ||
sheet, | ||
col = NULL, | ||
row = NULL, | ||
comment, | ||
dims = rowcol_to_dim(row, col), | ||
color = NULL, | ||
file = NULL | ||
) { | ||
.Deprecated("wb_add_comment()", package = "openxlsx2", old = "write_comment()") | ||
do_write_comment( | ||
wb, | ||
sheet, | ||
col, | ||
row, | ||
comment, | ||
dims, | ||
color, | ||
file | ||
) | ||
} | ||
|
||
#' @rdname comment_internal | ||
#' @param gridExpand If `TRUE`, all data in rectangle min(rows):max(rows) X min(cols):max(cols) | ||
#' will be removed. | ||
#' @keywords internal | ||
#' @export | ||
remove_comment <- function( | ||
wb, | ||
sheet, | ||
col = NULL, | ||
row = NULL, | ||
gridExpand = TRUE, | ||
dims = NULL | ||
) { | ||
.Deprecated("wb_remove_comment()", package = "openxlsx2", old = "remove_comment()") | ||
do_remove_comment( | ||
wb, | ||
sheet, | ||
col, | ||
row, | ||
gridExpand, | ||
dims | ||
) | ||
} | ||
|
||
#' Convert to Excel data | ||
#' | ||
#' Use [convert_to_excel_date()]. | ||
#' @usage NULL | ||
#' @inheritParams convert_to_excel_date | ||
#' @keywords internal | ||
#' @export | ||
convertToExcelDate <- function(df, date1904 = FALSE) { | ||
.Deprecated(old = "convertToExcelDate", new = "convert_to_excel_date", package = "openxlsx2") | ||
olivroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stop("convertToExcelDate() is defunct and will be removed in new version. Use convert_to_excel_date().", call. = FALSE) | ||
} | ||
|
||
#' Write an object to a worksheet | ||
#' | ||
#' Use [wb_add_data()] or [write_xlsx()] in new code. | ||
#' | ||
#' @inheritParams wb_add_data | ||
#' @return invisible(0) | ||
#' @export | ||
#' @keywords internal | ||
write_data <- function( | ||
wb, | ||
sheet, | ||
x, | ||
dims = wb_dims(start_row, start_col), | ||
start_col = 1, | ||
start_row = 1, | ||
array = FALSE, | ||
col_names = TRUE, | ||
row_names = FALSE, | ||
with_filter = FALSE, | ||
sep = ", ", | ||
name = NULL, | ||
apply_cell_style = TRUE, | ||
remove_cell_style = FALSE, | ||
na.strings = na_strings(), | ||
inline_strings = TRUE, | ||
enforce = FALSE, | ||
... | ||
) { | ||
.Deprecated("wb_add_data()", package = "openxlsx2", old = "write_data()") | ||
do_write_data( | ||
wb = wb, | ||
sheet = sheet, | ||
x = x, | ||
dims = dims, | ||
start_col = start_col, | ||
start_row = start_col, | ||
array = array, | ||
col_names = col_names, | ||
row_names = row_names, | ||
with_filter = with_filter, | ||
sep = sep, | ||
name = name, | ||
apply_cell_style = apply_cell_style, | ||
remove_cell_style = remove_cell_style, | ||
na.strings = na.strings, | ||
inline_strings = inline_strings, | ||
enforce = enforce, | ||
... | ||
) | ||
} | ||
|
||
#' Write to a worksheet as an Excel table | ||
#' | ||
#' Write to a worksheet and format as an Excel table. Use [wb_add_data_table()] in new code. | ||
#' This function is deprecated and may not be exported in the future. | ||
#' @inheritParams wb_add_data_table | ||
#' @inherit wb_add_data_table details | ||
#' @export | ||
#' @keywords internal | ||
write_datatable <- function( | ||
wb, | ||
sheet, | ||
x, | ||
dims = wb_dims(start_row, start_col), | ||
start_col = 1, | ||
start_row = 1, | ||
col_names = TRUE, | ||
row_names = FALSE, | ||
table_style = "TableStyleLight9", | ||
table_name = NULL, | ||
with_filter = TRUE, | ||
sep = ", ", | ||
first_column = FALSE, | ||
last_column = FALSE, | ||
banded_rows = TRUE, | ||
banded_cols = FALSE, | ||
apply_cell_style = TRUE, | ||
remove_cell_style = FALSE, | ||
na.strings = na_strings(), | ||
inline_strings = TRUE, | ||
total_row = FALSE, | ||
... | ||
) { | ||
.Deprecated("wb_add_data_table()", package = "openxlsx2", old = "write_datatable") | ||
olivroy marked this conversation as resolved.
Show resolved
Hide resolved
olivroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
do_write_datatable( | ||
wb = wb, | ||
sheet = sheet, | ||
x = x, | ||
dims = dims, | ||
start_col = start_col, | ||
start_row = start_row, | ||
col_names = col_names, | ||
row_names = row_names, | ||
table_style = table_style, | ||
table_name = table_name, | ||
with_filter = with_filter, | ||
sep = sep, | ||
first_column = first_column, | ||
last_column = last_column, | ||
banded_rows = banded_rows, | ||
banded_cols = banded_cols, | ||
apply_cell_style = apply_cell_style, | ||
remove_cell_style = remove_cell_style, | ||
na.strings = na.strings, | ||
inline_strings = inline_strings, | ||
total_row = total_row, | ||
... | ||
|
||
) | ||
} | ||
|
||
#' Write a character vector as an Excel Formula | ||
#' | ||
#' Write a a character vector containing Excel formula to a worksheet. | ||
#' Use [wb_add_formula()] or `add_formula()` in new code. This function is | ||
#' deprecated and may be defunct. | ||
#' | ||
#' @inheritParams wb_add_formula | ||
#' @export | ||
#' @keywords internal | ||
write_formula <- function( | ||
wb, | ||
sheet, | ||
x, | ||
dims = wb_dims(start_row, start_col), | ||
start_col = 1, | ||
start_row = 1, | ||
array = FALSE, | ||
cm = FALSE, | ||
apply_cell_style = TRUE, | ||
remove_cell_style = FALSE, | ||
enforce = FALSE, | ||
... | ||
) { | ||
.Deprecated("wb_add_formula()", package = "openxlsx2", old = "write_formula") | ||
olivroy marked this conversation as resolved.
Show resolved
Hide resolved
olivroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
do_write_formula( | ||
wb = wb, | ||
sheet = sheet, | ||
x = x, | ||
dims = dims, | ||
start_col = start_col, | ||
start_row = start_row, | ||
array = array, | ||
cm = cm, | ||
apply_cell_style = apply_cell_style, | ||
remove_cell_style = remove_cell_style, | ||
enforce = enforce, | ||
... | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess we can remove this line? The code will stop on the next either way. Should we still export this? I would simply no longer export this and drop the function after a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we stop exporting. People using it will get function not found, which is basically equivalent to dropping it fully (which I don't mind doing) I couldn't find any usage on GitHub. But no. Let's keep it like this.
Otherwise, people will not get the nudge to use
convert_to_excel_date()