Learn R Programming

openxlsx2 (version 0.5.1)

create_sparklines: create sparklines used in add_sparline()

Description

create sparklines used in add_sparline()

Usage

create_sparklines(
  sheet = current_sheet(),
  dims,
  sqref,
  type = NULL,
  negative = NULL,
  displayEmptyCellsAs = "gap",
  markers = NULL,
  high = NULL,
  low = NULL,
  first = NULL,
  last = NULL,
  colorSeries = wb_color(hex = "FF376092"),
  colorNegative = wb_color(hex = "FFD00000"),
  colorAxis = wb_color(hex = "FFD00000"),
  colorMarkers = wb_color(hex = "FFD00000"),
  colorFirst = wb_color(hex = "FFD00000"),
  colorLast = wb_color(hex = "FFD00000"),
  colorHigh = wb_color(hex = "FFD00000"),
  colorLow = wb_color(hex = "FFD00000")
)

Arguments

sheet

sheet

dims

dims

sqref

sqref

type

type

negative

negative

displayEmptyCellsAs

displayEmptyCellsAs

markers

markers add marker to line

high

highlight highest value

low

highlight lowest value

first

highlight first value

last

highlight last value

colorSeries

colorSeries

colorNegative

colorNegative

colorAxis

colorAxis

colorMarkers

colorMarkers

colorFirst

colorFirst

colorLast

colorLast

colorHigh

colorHigh

colorLow

colorLow

Details

the colors are all predefined to be rgb. Maybe theme colors can be used too.

Examples

Run this code
# create sparklineGroup
sparklines <- c(
  create_sparklines("Sheet 1", "A3:L3", "M3", type = "column", first = "1"),
  create_sparklines("Sheet 1", "A2:L2", "M2", markers = "1"),
  create_sparklines("Sheet 1", "A4:L4", "M4", type = "stacked", negative = "1")
)

t1 <- AirPassengers
t2 <- do.call(cbind, split(t1, cycle(t1)))
dimnames(t2) <- dimnames(.preformat.ts(t1))

wb <- wb_workbook()$
  add_worksheet("Sheet 1")$
  add_data(x = t2)$
  add_sparklines(sparklines = sparklines)

Run the code above in your browser using DataLab