@@ -457,6 +457,35 @@ create_sparklines <- function(
457457 if (! is.null(markers ) && as_xml_attr(markers ) == " " && ! is.null(type ) && type %in% c(" stacked" , " column" ))
458458 stop(" markers only affect lines `type = NULL`, not stacked or column" )
459459
460+ dims_helper <- function (x ) {
461+ rc <- dims_to_rowcol(x , as_integer = TRUE )
462+
463+ vapply(rc [[2 ]], function (row ) {
464+ rowcol_to_dims(
465+ row = row ,
466+ col = seq.int(min(rc [[1 ]]), max(rc [[1 ]])))
467+ }, FUN.VALUE = character (1 ))
468+ }
469+
470+ dims <- dims_helper(dims )
471+ sqref <- dims_helper(sqref )
472+
473+ sparkline <- Map(
474+ function (dims , sqref ) {
475+ xml_node_create(
476+ " x14:sparkline" , xml_children = c(
477+ xml_node_create(
478+ " xm:f" , xml_children = c(
479+ paste0(shQuote(sheet , type = " sh" ), " !" , dims )
480+ )),
481+ xml_node_create(
482+ " xm:sqref" , xml_children = c(
483+ sqref
484+ ))
485+ ))
486+ }, dims , sqref )
487+ sparklines <- paste(unlist(sparkline ), collapse = " " )
488+
460489 sparklineGroup <- xml_node_create(
461490 " x14:sparklineGroup" ,
462491 xml_attributes = c(
@@ -489,19 +518,7 @@ create_sparklines <- function(
489518 xml_node_create(" x14:colorHigh" , xml_attributes = color_high ),
490519 xml_node_create(" x14:colorLow" , xml_attributes = color_low ),
491520 xml_node_create(
492- " x14:sparklines" , xml_children = c(
493- xml_node_create(
494- " x14:sparkline" , xml_children = c(
495- xml_node_create(
496- " xm:f" , xml_children = c(
497- paste0(shQuote(sheet , type = " sh" ), " !" , dims )
498- )),
499- xml_node_create(
500- " xm:sqref" , xml_children = c(
501- sqref
502- ))
503- ))
504- )
521+ " x14:sparklines" , xml_children = sparklines
505522 )
506523 )
507524 )
0 commit comments