Skip to content

Commit ad2f722

Browse files
committed
adjust a few col widths to share the same default
1 parent b58db02 commit ad2f722

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

R/class-workbook-wrappers.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ wb_set_row_heights <- function(wb, sheet = current_sheet(), rows, heights) {
611611
#' wb$add_worksheet("Sheet 2")
612612
#' wb$add_data(sheet = 2, x = iris)
613613
#' wb$set_col_widths(sheet = 2, cols = 1:5, widths = "auto")
614-
wb_set_col_widths <- function(wb, sheet = current_sheet(), cols, widths = 10, hidden = FALSE) {
614+
wb_set_col_widths <- function(wb, sheet = current_sheet(), cols, widths = 8.43, hidden = FALSE) {
615615
assert_workbook(wb)
616616
wb$clone()$set_col_widths(
617617
sheet = sheet,

R/class-workbook.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,7 @@ wbWorkbook <- R6::R6Class(
22092209
#' @param hidden A logical vector to determine which cols are hidden; values
22102210
#' are repeated across length of `cols`
22112211
#' @return The `wbWorkbook` object, invisibly
2212-
set_col_widths = function(sheet = current_sheet(), cols, widths = 10, hidden = FALSE) {
2212+
set_col_widths = function(sheet = current_sheet(), cols, widths = 8.43, hidden = FALSE) {
22132213
sheet <- private$get_sheet_index(sheet)
22142214

22152215
# should do nothing if the cols' length is zero

R/class-worksheet.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ empty_cols_attr <- function(n = 0, beg, end) {
714714
if (n > 0) {
715715
z$min <- n_seq
716716
z$max <- n_seq
717-
z$width <- "11.375" # default width in MS365 Desktop for Mac
717+
z$width <- "8.43"
718718
}
719719

720720
z

tests/testthat/test-class-workbook.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ test_that("wb_set_col_widths", {
2323
# reset the column with, we do not provide an option ot remove the column entry
2424
expect_silent(wb$set_col_widths("test", cols = seq_along(mtcars)))
2525
expect_equal(
26-
"<col min=\"1\" max=\"11\" bestFit=\"1\" customWidth=\"1\" hidden=\"false\" width=\"10.875\"/>",
26+
"<col min=\"1\" max=\"11\" bestFit=\"1\" customWidth=\"1\" hidden=\"false\" width=\"9.305\"/>",
2727
wb$worksheets[[1]]$cols_attr
2828
)
2929

3030
# create column width for column 25
3131
expect_silent(wb$set_col_widths("test", cols = "Y", widths = 22))
3232
expect_equal(
33-
c("<col min=\"1\" max=\"11\" bestFit=\"1\" customWidth=\"1\" hidden=\"false\" width=\"10.875\"/>",
34-
"<col min=\"12\" max=\"24\" width=\"11.375\"/>",
33+
c("<col min=\"1\" max=\"11\" bestFit=\"1\" customWidth=\"1\" hidden=\"false\" width=\"9.305\"/>",
34+
"<col min=\"12\" max=\"24\" width=\"8.43\"/>",
3535
"<col min=\"25\" max=\"25\" bestFit=\"1\" customWidth=\"1\" hidden=\"false\" width=\"22.875\"/>"),
3636
wb$worksheets[[1]]$cols_attr
3737
)

0 commit comments

Comments
 (0)