File: worksheetOrder.Rd

package info (click to toggle)
r-cran-openxlsx 4.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: cpp: 1,867; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,411 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{worksheetOrder}
\alias{worksheetOrder}
\alias{worksheetOrder<-}
\title{Order of worksheets in xlsx file}
\usage{
worksheetOrder(wb)

worksheetOrder(wb) <- value
}
\arguments{
\item{wb}{A workbook object}

\item{value}{Vector specifying order to write worksheets to file}
}
\description{
Get/set order of worksheets in a Workbook object
}
\details{
This function does not reorder the worksheets within the workbook object, it simply
shuffles the order when writing to file.
}
\examples{
## setup a workbook with 3 worksheets
wb <- createWorkbook()
addWorksheet(wb = wb, sheetName = "Sheet 1", gridLines = FALSE)
writeDataTable(wb = wb, sheet = 1, x = iris)

addWorksheet(wb = wb, sheetName = "mtcars (Sheet 2)", gridLines = FALSE)
writeData(wb = wb, sheet = 2, x = mtcars)

addWorksheet(wb = wb, sheetName = "Sheet 3", gridLines = FALSE)
writeData(wb = wb, sheet = 3, x = Formaldehyde)

worksheetOrder(wb)
names(wb)
worksheetOrder(wb) <- c(1, 3, 2) # switch position of sheets 2 & 3
writeData(wb, 2, 'This is still the "mtcars" worksheet', startCol = 15)
worksheetOrder(wb)
names(wb) ## ordering within workbook is not changed
\dontrun{
saveWorkbook(wb, "worksheetOrderExample.xlsx", overwrite = TRUE)
}
worksheetOrder(wb) <- c(3, 2, 1)
\dontrun{
saveWorkbook(wb, "worksheetOrderExample2.xlsx", overwrite = TRUE)
}
}