11# https://developers.google.com/sheets/api/samples/formatting#format_a_header_row
22# returns: a wrapped instance of RepeatCellRequest
3- bureq_header_row <- function (row = 1 ,
4- sheetId = NULL ,
5- backgroundColor = 0.92 ,
6- horizontalAlignment = " CENTER" ,
7- bold = TRUE ) {
3+ bureq_header_row <- function (
4+ row = 1 ,
5+ sheetId = NULL ,
6+ backgroundColor = 0.92 ,
7+ horizontalAlignment = " CENTER" ,
8+ bold = TRUE
9+ ) {
810 row <- row - 1 # indices are zero-based; intervals are half open: [start, end)
911 grid_range <- new(
1012 " GridRange" ,
@@ -19,9 +21,9 @@ bureq_header_row <- function(row = 1,
1921 backgroundColor = new(
2022 " Color" ,
2123 # I want a shade of grey
22- red = backgroundColor ,
24+ red = backgroundColor ,
2325 green = backgroundColor ,
24- blue = backgroundColor
26+ blue = backgroundColor
2527 ),
2628 textFormat = new(
2729 " TextFormat" ,
@@ -35,30 +37,37 @@ bureq_header_row <- function(row = 1,
3537 # example: Color's other child, alpha
3638 fields <- " userEnteredFormat(horizontalAlignment,backgroundColor,textFormat)"
3739
38- list (repeatCell = new(
39- " RepeatCellRequest" ,
40- range = grid_range ,
41- cell = cell_data ,
42- fields = fields
43- ))
40+ list (
41+ repeatCell = new(
42+ " RepeatCellRequest" ,
43+ range = grid_range ,
44+ cell = cell_data ,
45+ fields = fields
46+ )
47+ )
4448}
4549
4650# based on this, except I clear everything by sending 'fields = "*"'
4751# https://developers.google.com/sheets/api/samples/sheet#clear_a_sheet_of_all_values_while_preserving_formats
4852# returns: a wrapped instance of RepeatCellRequest
4953bureq_clear_sheet <- function (sheetId ) {
50- list (repeatCell = new(
51- " RepeatCellRequest" ,
52- range = new(" GridRange" , sheetId = sheetId ),
53- fields = " *"
54- ))
54+ list (
55+ repeatCell = new(
56+ " RepeatCellRequest" ,
57+ range = new(" GridRange" , sheetId = sheetId ),
58+ fields = " *"
59+ )
60+ )
5561}
5662
5763# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#UpdateSheetPropertiesRequest
58- bureq_set_grid_properties <- function (sheetId ,
59- nrow = NULL , ncol = NULL ,
60- frozenRowCount = 1 ,
61- frozenColumnCount = NULL ) {
64+ bureq_set_grid_properties <- function (
65+ sheetId ,
66+ nrow = NULL ,
67+ ncol = NULL ,
68+ frozenRowCount = 1 ,
69+ frozenColumnCount = NULL
70+ ) {
6271 gp <- new(" GridProperties" , rowCount = nrow , columnCount = ncol )
6372 if (! is.null(frozenRowCount ) && frozenRowCount > 0 ) {
6473 gp <- patch(gp , frozenRowCount = frozenRowCount )
@@ -71,19 +80,23 @@ bureq_set_grid_properties <- function(sheetId,
7180 }
7281
7382 sp <- new(" SheetProperties" , sheetId = sheetId , gridProperties = gp )
74- list (updateSheetProperties = new(
75- " UpdateSheetPropertiesRequest" ,
76- properties = sp ,
77- fields = gargle :: field_mask(sp )
78- ))
83+ list (
84+ updateSheetProperties = new(
85+ " UpdateSheetPropertiesRequest" ,
86+ properties = sp ,
87+ fields = gargle :: field_mask(sp )
88+ )
89+ )
7990}
8091
8192# https://developers.google.com/sheets/api/samples/rowcolumn#automatically_resize_a_column
8293# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#AutoResizeDimensionsRequest
83- bureq_auto_resize_dimensions <- function (sheetId ,
84- dimension = c(" COLUMNS" , " ROWS" ),
85- start = NULL ,
86- end = NULL ) {
94+ bureq_auto_resize_dimensions <- function (
95+ sheetId ,
96+ dimension = c(" COLUMNS" , " ROWS" ),
97+ start = NULL ,
98+ end = NULL
99+ ) {
87100 dimension <- match.arg(dimension )
88101 # https://developers.google.com/sheets/api/reference/rest/v4/DimensionRange
89102 # A range along a single dimension on a sheet. All indexes are zero-based.
@@ -102,8 +115,10 @@ bureq_auto_resize_dimensions <- function(sheetId,
102115 check_non_negative_integer(end )
103116 dimension_range <- patch(dimension_range , endIndex = end )
104117 }
105- list (autoResizeDimensions = new(
106- " AutoResizeDimensionsRequest" ,
107- dimensions = dimension_range
108- ))
118+ list (
119+ autoResizeDimensions = new(
120+ " AutoResizeDimensionsRequest" ,
121+ dimensions = dimension_range
122+ )
123+ )
109124}
0 commit comments