/
excel.worksheetchangedeventargs.yml
267 lines (233 loc) · 11 KB
/
excel.worksheetchangedeventargs.yml
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
### YamlMime:TSType
name: Excel.WorksheetChangedEventArgs
uid: 'excel!Excel.WorksheetChangedEventArgs:interface'
package: excel!
fullName: Excel.WorksheetChangedEventArgs
summary: Provides information about the worksheet that raised the changed event.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: interface
properties:
- name: address
uid: 'excel!Excel.WorksheetChangedEventArgs#address:member'
package: excel!
fullName: address
summary: Gets the range address that represents the changed area of a specific worksheet.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'address: string;'
return:
type: string
- name: changeDirectionState
uid: 'excel!Excel.WorksheetChangedEventArgs#changeDirectionState:member'
package: excel!
fullName: changeDirectionState
summary: >-
Represents a change to the direction that the cells in a worksheet will shift when a cell or cells are deleted or
inserted. This includes the following two scenarios. 1. The direction (such as down or to the right) that existing
cells will shift when a new cell or cells are inserted into a worksheet. 2. The direction (such as up or to the
left) that the remaining cells will shift when a cell or cells are deleted from a worksheet.
remarks: >-
\[ [API set: ExcelApi 1.14](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml
async function onChange(event: Excel.WorksheetChangedEventArgs) {
// This function is an event handler that returns the address, trigger source,
// and insert or delete shift directions of the change.
await Excel.run(async (context) => {
// Return the address where change occurred.
console.log(`Handler for worksheet onChanged event has been triggered.`);
console.log(` Data changed address: ` + event.address);
// Return the source of the event that triggered the change.
console.log(` Data change trigger source: ` + event.triggerSource);
// Note:insertShiftDirection and deleteShiftDirection are exclusive and both enums can't have a value at the same time.
// If one has a value, then the other will return undefined.
// If the insert shift direction is defined, return it.
if (event.changeDirectionState.insertShiftDirection) {
console.log(` Cells inserted shift direction: ` + event.changeDirectionState.insertShiftDirection);
}
// If the delete shift direction is defined, return it.
if (event.changeDirectionState.deleteShiftDirection) {
console.log(` Cells deleted shift direction: ` + event.changeDirectionState.deleteShiftDirection);
}
});
}
...
// This function deletes data from a range and sets the delete shift direction to "up".
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
const range = sheet.getRange("A5:F5");
range.delete(Excel.DeleteShiftDirection.up);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'changeDirectionState: Excel.ChangeDirectionState;'
return:
type: '<xref uid="excel!Excel.ChangeDirectionState:interface" />'
- name: changeType
uid: 'excel!Excel.WorksheetChangedEventArgs#changeType:member'
package: excel!
fullName: changeType
summary: Gets the change type that represents how the changed event is triggered. See `Excel.DataChangeType` for details.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: >-
changeType: Excel.DataChangeType | "Unknown" | "RangeEdited" | "RowInserted" | "RowDeleted" | "ColumnInserted" |
"ColumnDeleted" | "CellInserted" | "CellDeleted";
return:
type: >-
<xref uid="excel!Excel.DataChangeType:enum" /> | "Unknown" | "RangeEdited" | "RowInserted" | "RowDeleted" |
"ColumnInserted" | "ColumnDeleted" | "CellInserted" | "CellDeleted"
- name: details
uid: 'excel!Excel.WorksheetChangedEventArgs#details:member'
package: excel!
fullName: details
summary: >-
Represents the information about the change detail. This property can be retrieved when the changed event is
triggered on a single cell. If the changed event is triggered on multiple cells, this property cannot be
retrieved.
remarks: |-
\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// This function would be used as an event handler for the Worksheet.onChanged event.
async function onWorksheetChanged(eventArgs) {
await Excel.run(async (context) => {
const details = eventArgs.details;
const address = eventArgs.address;
// Print the before and after types and values to the console.
console.log(`Change at ${address}: was ${details.valueBefore}(${details.valueTypeBefore}),`
+ ` now is ${details.valueAfter}(${details.valueTypeAfter})`);
await context.sync();
});
}
```
isPreview: false
isDeprecated: false
syntax:
content: 'details: Excel.ChangedEventDetail;'
return:
type: '<xref uid="excel!Excel.ChangedEventDetail:interface" />'
- name: source
uid: 'excel!Excel.WorksheetChangedEventArgs#source:member'
package: excel!
fullName: source
summary: Gets the source of the event. See `Excel.EventSource` for details.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'source: Excel.EventSource | "Local" | "Remote";'
return:
type: '<xref uid="excel!Excel.EventSource:enum" /> | "Local" | "Remote"'
- name: triggerSource
uid: 'excel!Excel.WorksheetChangedEventArgs#triggerSource:member'
package: excel!
fullName: triggerSource
summary: 'Represents the trigger source of the event. For example, identifies whether this local add-in triggers the event.'
remarks: >-
\[ [API set: ExcelApi 1.14](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml
async function onChange(event: Excel.WorksheetChangedEventArgs) {
// This function is an event handler that returns the address, trigger source,
// and insert or delete shift directions of the change.
await Excel.run(async (context) => {
// Return the address where change occurred.
console.log(`Handler for worksheet onChanged event has been triggered.`);
console.log(` Data changed address: ` + event.address);
// Return the source of the event that triggered the change.
console.log(` Data change trigger source: ` + event.triggerSource);
// Note:insertShiftDirection and deleteShiftDirection are exclusive and both enums can't have a value at the same time.
// If one has a value, then the other will return undefined.
// If the insert shift direction is defined, return it.
if (event.changeDirectionState.insertShiftDirection) {
console.log(` Cells inserted shift direction: ` + event.changeDirectionState.insertShiftDirection);
}
// If the delete shift direction is defined, return it.
if (event.changeDirectionState.deleteShiftDirection) {
console.log(` Cells deleted shift direction: ` + event.changeDirectionState.deleteShiftDirection);
}
});
}
```
isPreview: false
isDeprecated: false
syntax:
content: 'triggerSource: Excel.EventTriggerSource | "Unknown" | "ThisLocalAddin";'
return:
type: '<xref uid="excel!Excel.EventTriggerSource:enum" /> | "Unknown" | "ThisLocalAddin"'
- name: type
uid: 'excel!Excel.WorksheetChangedEventArgs#type:member'
package: excel!
fullName: type
summary: Gets the type of the event. See `Excel.EventType` for details.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'type: "WorksheetChanged";'
return:
type: '"WorksheetChanged"'
- name: worksheetId
uid: 'excel!Excel.WorksheetChangedEventArgs#worksheetId:member'
package: excel!
fullName: worksheetId
summary: Gets the ID of the worksheet in which the data changed.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'worksheetId: string;'
return:
type: string
methods:
- name: getRange(ctx)
uid: 'excel!Excel.WorksheetChangedEventArgs#getRange:member(1)'
package: excel!
fullName: getRange(ctx)
summary: |-
Gets the range that represents the changed area of a specific worksheet.
\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'getRange(ctx: Excel.RequestContext): Excel.Range;'
parameters:
- id: ctx
description: ''
type: '<xref uid="excel!Excel.RequestContext:class" />'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getRangeOrNullObject(ctx)
uid: 'excel!Excel.WorksheetChangedEventArgs#getRangeOrNullObject:member(1)'
package: excel!
fullName: getRangeOrNullObject(ctx)
summary: |-
Gets the range that represents the changed area of a specific worksheet. It might return null object.
\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'getRangeOrNullObject(ctx: Excel.RequestContext): Excel.Range;'
parameters:
- id: ctx
description: ''
type: '<xref uid="excel!Excel.RequestContext:class" />'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''