-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathnamed_region.Rd
163 lines (123 loc) · 3.83 KB
/
named_region.Rd
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/class-workbook-wrappers.R,
% R/get-named-regions.R
\name{named_region}
\alias{named_region}
\alias{wb_add_named_region}
\alias{wb_remove_named_region}
\alias{get_named_regions}
\alias{wb_get_named_regions}
\title{Create / delete a named region}
\usage{
wb_add_named_region(
wb,
sheet = current_sheet(),
cols,
rows,
name,
localSheet = FALSE,
overwrite = FALSE,
comment = NULL,
customMenu = NULL,
description = NULL,
is_function = NULL,
functionGroupId = NULL,
help = NULL,
hidden = NULL,
localName = NULL,
publishToServer = NULL,
statusBar = NULL,
vbProcedure = NULL,
workbookParameter = NULL,
xml = NULL
)
wb_remove_named_region(wb, sheet = current_sheet(), name = NULL)
get_named_regions(x)
wb_get_named_regions(x, tables = FALSE)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{Numeric vector specifying columns to include in region}
\item{rows}{Numeric vector specifying rows to include in region}
\item{name}{Name for region. A character vector of length 1. Note region names musts be case-insensitive unique.}
\item{localSheet}{If \code{TRUE} the named region will be local for this sheet}
\item{overwrite}{Boolean. Overwrite if exists? Default to FALSE}
\item{comment}{description text for named region}
\item{customMenu}{customMenu (unknown xml feature)}
\item{description}{description (unknown xml feature)}
\item{is_function}{function (unknown xml feature)}
\item{functionGroupId}{function group id (unknown xml feature)}
\item{help}{help (unknown xml feature)}
\item{hidden}{hidden if the named region should be hidden}
\item{localName}{localName (unknown xml feature)}
\item{publishToServer}{publish to server (unknown xml feature)}
\item{statusBar}{status bar (unknown xml feature)}
\item{vbProcedure}{wbProcedure (unknown xml feature)}
\item{workbookParameter}{workbookParameter (unknown xml feature)}
\item{xml}{xml (unknown xml feature)}
\item{x}{An xlsx file or Workbook object}
\item{tables}{add tables too}
}
\description{
Create / delete a named region
Return a vector of named regions in a xlsx file or
Workbook object
}
\details{
Region is given by: min(cols):max(cols) X min(rows):max(rows)
}
\examples{
## create named regions
wb <- wb_workbook()
wb$add_worksheet("Sheet 1")
## specify region
wb$add_data(sheet = 1, x = iris, startCol = 1, startRow = 1)
wb$add_named_region(
sheet = 1,
name = "iris",
rows = seq_len(nrow(iris) + 1),
cols = seq_along(iris)
)
## using write_data 'name' argument
wb$add_data(sheet = 1, x = iris, name = "iris2", startCol = 10)
out_file <- temp_xlsx()
wb_save(wb, out_file, overwrite = TRUE)
## see named regions
wb_get_named_regions(wb) ## From Workbook object
wb_get_named_regions(out_file) ## From xlsx file
## delete one
wb$remove_named_region(name = "iris2")
wb_get_named_regions(wb)
## read named regions
df <- read_xlsx(wb, namedRegion = "iris")
head(df)
df <- read_xlsx(out_file, namedRegion = "iris2")
head(df)
## create named regions
wb <- wb_workbook()
wb$add_worksheet("Sheet 1")
## specify region
wb$add_data(sheet = 1, x = iris, startCol = 1, startRow = 1)
wb$add_named_region(
sheet = 1,
name = "iris",
rows = seq_len(nrow(iris) + 1),
cols = seq_along(iris)
)
## using write_data 'name' argument to create a named region
wb$add_data(sheet = 1, x = iris, name = "iris2", startCol = 10)
out_file <- temp_xlsx()
wb$save(out_file, overwrite = TRUE)
## see named regions
wb_get_named_regions(wb) ## From Workbook object
wb_get_named_regions(out_file) ## From xlsx file
## read named regions
df <- read_xlsx(wb, namedRegion = "iris")
head(df)
df <- read_xlsx(out_file, namedRegion = "iris2")
head(df)
}
\seealso{
\code{\link[=wb_add_named_region]{wb_add_named_region()}} \code{\link[=wb_remove_named_region]{wb_remove_named_region()}}
}