File: protectWorksheet.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 (90 lines) | stat: -rw-r--r-- 2,533 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{protectWorksheet}
\alias{protectWorksheet}
\title{Protect a worksheet from modifications}
\usage{
protectWorksheet(
  wb,
  sheet,
  protect = TRUE,
  password = NULL,
  lockSelectingLockedCells = NULL,
  lockSelectingUnlockedCells = NULL,
  lockFormattingCells = NULL,
  lockFormattingColumns = NULL,
  lockFormattingRows = NULL,
  lockInsertingColumns = NULL,
  lockInsertingRows = NULL,
  lockInsertingHyperlinks = NULL,
  lockDeletingColumns = NULL,
  lockDeletingRows = NULL,
  lockSorting = NULL,
  lockAutoFilter = NULL,
  lockPivotTables = NULL,
  lockObjects = NULL,
  lockScenarios = NULL
)
}
\arguments{
\item{wb}{A workbook object}

\item{sheet}{A name or index of a worksheet}

\item{protect}{Whether to protect or unprotect the sheet (default=TRUE)}

\item{password}{(optional) password required to unprotect the worksheet}

\item{lockSelectingLockedCells}{Whether selecting locked cells is locked}

\item{lockSelectingUnlockedCells}{Whether selecting unlocked cells is locked}

\item{lockFormattingCells}{Whether formatting cells is locked}

\item{lockFormattingColumns}{Whether formatting columns is locked}

\item{lockFormattingRows}{Whether formatting rows is locked}

\item{lockInsertingColumns}{Whether inserting columns is locked}

\item{lockInsertingRows}{Whether inserting rows is locked}

\item{lockInsertingHyperlinks}{Whether inserting hyperlinks is locked}

\item{lockDeletingColumns}{Whether deleting columns is locked}

\item{lockDeletingRows}{Whether deleting rows is locked}

\item{lockSorting}{Whether sorting is locked}

\item{lockAutoFilter}{Whether auto-filter is locked}

\item{lockPivotTables}{Whether pivot tables are locked}

\item{lockObjects}{Whether objects are locked}

\item{lockScenarios}{Whether scenarios are locked}
}
\description{
Protect or unprotect a worksheet from modifications by the user in the graphical user interface. Replaces an existing protection.
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "S1")
writeDataTable(wb, 1, x = iris[1:30, ])
# Formatting cells / columns is allowed , but inserting / deleting columns is protected:
protectWorksheet(wb, "S1",
  protect = TRUE,
  lockFormattingCells = FALSE, lockFormattingColumns = FALSE,
  lockInsertingColumns = TRUE, lockDeletingColumns = TRUE
)

# Remove the protection
protectWorksheet(wb, "S1", protect = FALSE)
\dontrun{
saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)
}
}
\author{
Reinhold Kainhofer
}