fillCells: fillCells

View source: R/xlsxTools.R

fillCellsR Documentation

fillCells

Description

fillCells

Usage

fillCells(
  onesheet,
  line,
  col,
  ...,
  names = FALSE,
  colnames = FALSE,
  rownames = FALSE,
  style = NULL,
  styleRowsIndex = NULL,
  styleColsIndex = NULL,
  wb = NULL
)

Arguments

onesheet

A sheet object from xlsx package

line

The line where to paste value

col

The col where to paste value

...

List of N values to paste in col "col" to col+N if contain a data.frame, the dataframe is pasted at the position

names

if TRUE column and row names of the dataframe are displayed (overwrite colnames and rownames)

colnames

if TRUE column names of the dataframe are displayed

rownames

if TRUE row names of the dataframe are displayed

style

An optional style created with createXlsxStyle

styleRowsIndex

Numeric vector of the rown index where to apply the style

styleColsIndex

Numeric vector of the column index where to apply the style

wb

An optional wb if not already opened

Value

nothing

Examples


# Creating an empty workbook
wb <- openxlsx::createWorkbook()
sheetname <- "First Sheet"
openxlsx::addWorksheet(wb, sheetName = sheetname)
num <- 3
denum <- 10
fillCells(sheetname, 1, 1, num, denum , wb = wb)
mat <- data.frame(Id = 1:3 , Vaccs = c("1", "3", "6"))
fillCells(sheetname, 3, 1, mat, wb = wb)

# Writing a data frame in the workbook using a style to apply for a set of rows and columns
alertStyle <- createXlsxStyle(textDecoration = "Bold", fontColour = "red")
fillCells(wb = wb, 
          onesheet = sheetname, 
          line = 7, 
          col = 2, 
          iris, 
          style = alertStyle, 
          styleRowsIndex = which(iris$Sepal.Length<5),
          styleColsIndex = 1:4)
          
# Saving the Excelfile
## Not run: 
saveXlsx(filename = "test.xlsx", wb = wb)

## End(Not run)


Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.