Learn R Programming

xlsx (version 0.1.1)

OtherEffects: Functions to do various spreadsheets effects.

Description

Functions to do various spreadsheets effects.

Usage

addMergedRegion(sheet, startRow, endRow, startColumn, endColumn)

removeMergedRegion(sheet, ind)

autoSizeColumn(sheet, colIndex)

createFreezePane(sheet, rowSplit, colSplit, startRow=NULL, startColumn=NULL)

createSplitPane(sheet, xSplitPos=2000, ySplitPos=2000, startRow=1, startColumn=1, position="PANE_LOWER_LEFT")

setPrintArea(wb, sheetIndex, startColumn, endColumn, startRow, endRow)

setZoom(sheet, numerator=100, denominator=100)

Arguments

sheet
a Worksheet object.
startRow
a numeric value for the starting row.
endRow
a numeric value for the ending row.
startColumn
a numeric value for the starting column.
endColumn
a numeric value for the ending column.
ind
a numeric value indicating which merged region you want to remove.
position
a character. Valid value are "PANE_LOWER_LEFT", "PANE_LOWER_RIGHT", "PANE_UPPER_LEFT", "PANE_UPPER_RIGHT".
colIndex
a numeric vector specifiying the columns you want to auto size.
rowSplit
a numeric value for the row to split.
colSplit
a numeric value for the column to split.
xSplitPos
a numeric value for the horizontal position of split in 1/20 of a point.
ySplitPos
a numeric value for the vertical position of split in 1/20 of a point.
wb
a Workbook object.
sheetIndex
a numeric value for the worksheet index.
numerator
a numeric value representing the numerator of the zoom ratio.
denominator
a numeric value representing the denomiator of the zoom ratio.

Value

  • addMergedRegion returns a numeric value to label the merged region. You should use this value as the ind if you want to removeMergedRegion.

Details

You may need other functionality that is not exposed. Take a look at the java docs and the source code of these functions for how you can implement it in R.

Examples

Run this code
wb <- createWorkbook()
  sheet1 <- createSheet(wb, "Sheet1")
  rows   <- createRow(sheet1, 1:10)              # 10 rows
  cells  <- createCell(rows, colIndex=1:8)       # 8 columns

  cat("Merge cells 
")
  setCellValue(cells[[1,1]], "A title that spans 3 columns")
  addMergedRegion(sheet1, 1, 1, 1, 3)

  cat("Set zoom 2:1 
")
  setZoom(sheet1, 200, 100)

  sheet2 <- createSheet(wb, "Sheet2")
  rows  <- createRow(sheet2, 1:10)              # 10 rows
  cells <- createCell(rows, colIndex=1:8)       # 8 columns
  #createFreezePane(sheet2, 1, 1, 1, 1)
  createFreezePane(sheet2, 5, 5, 8, 8)
  
  sheet3 <- createSheet(wb, "Sheet3")
  rows  <- createRow(sheet3, 1:10)              # 10 rows
  cells <- createCell(rows, colIndex=1:8)       # 8 columns
  createSplitPane(sheet3, 2000, 2000, 1, 1, "PANE_LOWER_LEFT")
  
  # Don't forget to save the workbook ...

Run the code above in your browser using DataLab