@@ -99,7 +99,28 @@ methods:
99
99
type : ' (boolean | string | number)[]'
100
100
return :
101
101
type : void
102
- description : ' '
102
+ description : |-
103
+
104
+
105
+ #### Examples
106
+
107
+ ```TypeScript
108
+ /**
109
+ * This script adds a row to an existing table.
110
+ */
111
+ function main(workbook: ExcelScript.Workbook) {
112
+ // Get the first table in the current worksheet.
113
+ const selectedSheet = workbook.getActiveWorksheet();
114
+ const table = selectedSheet.getTables()[0];
115
+
116
+ // Initialize the data to be added as a table row.
117
+ // Note that length of the array must match the number of columns in the table.
118
+ let rowData = ["Carrots", "Vegetable", 750];
119
+
120
+ // Add a row to the end of the table.
121
+ table.addRow(-1, rowData);
122
+ }
123
+ ```
103
124
- name : ' addRows(index, values)'
104
125
uid : ' ExcelScript!ExcelScript.Table#addRows:member(1)'
105
126
package : ExcelScript!
@@ -121,7 +142,30 @@ methods:
121
142
type : ' (boolean | string | number)[][]'
122
143
return :
123
144
type : void
124
- description : ' '
145
+ description : |-
146
+
147
+
148
+ #### Examples
149
+
150
+ ```TypeScript
151
+ /**
152
+ * This script adds multiple rows to an existing table.
153
+ */
154
+ function main(workbook: ExcelScript.Workbook) {
155
+ // Get the first table in the current worksheet.
156
+ const selectedSheet = workbook.getActiveWorksheet();
157
+ const table = selectedSheet.getTables()[0];
158
+
159
+ // Initialize the data to be added as table rows.
160
+ // Note that length of the array must match the number of columns in the table.
161
+ let rowData = [["Apples", "Fruit", 5000],
162
+ ["Celery", "Vegetable", 600],
163
+ ["Onions", "Vegetable", 1500]];
164
+
165
+ // Add the rows to the end of the table.
166
+ table.addRows(-1, rowData);
167
+ }
168
+ ```
125
169
- name : clearFilters()
126
170
uid : ' ExcelScript!ExcelScript.Table#clearFilters:member(1)'
127
171
package : ExcelScript!
@@ -147,7 +191,27 @@ methods:
147
191
content : ' convertToRange(): Range;'
148
192
return :
149
193
type : ' <xref uid="ExcelScript!ExcelScript.Range:interface" />'
150
- description : ' '
194
+ description : |-
195
+
196
+
197
+ #### Examples
198
+
199
+ ```TypeScript
200
+ /**
201
+ * This script converts a table to a range and removes the formatting.
202
+ */
203
+ function main(workbook: ExcelScript.Workbook) {
204
+ // Get the first table in the current worksheet.
205
+ const selectedSheet = workbook.getActiveWorksheet();
206
+ const table = selectedSheet.getTables()[0];
207
+
208
+ // Convert the table to a range.
209
+ const formerTable = table.convertToRange();
210
+
211
+ // Remove the formatting from the table
212
+ formerTable.clear(ExcelScript.ClearApplyTo.formats);
213
+ }
214
+ ```
151
215
- name : delete()
152
216
uid : ' ExcelScript!ExcelScript.Table#delete:member(1)'
153
217
package : ExcelScript!
@@ -160,7 +224,24 @@ methods:
160
224
content : ' delete(): void;'
161
225
return :
162
226
type : void
163
- description : ' '
227
+ description : |-
228
+
229
+
230
+ #### Examples
231
+
232
+ ```TypeScript
233
+ /**
234
+ * This script deletes a table.
235
+ * This removes all associated data and formatting.
236
+ */
237
+ function main(workbook: ExcelScript.Workbook) {
238
+ // Get the table named "Inventory".
239
+ const table = workbook.getTable("Inventory");
240
+
241
+ // Delete the table.
242
+ table.delete();
243
+ }
244
+ ```
164
245
- name : ' deleteRowsAt(index, count)'
165
246
uid : ' ExcelScript!ExcelScript.Table#deleteRowsAt:member(1)'
166
247
package : ExcelScript!
@@ -269,7 +350,26 @@ methods:
269
350
type : string
270
351
return :
271
352
type : ' <xref uid="ExcelScript!ExcelScript.TableColumn:interface" /> | undefined'
272
- description : ' '
353
+ description : |-
354
+
355
+
356
+ #### Examples
357
+
358
+ ```TypeScript
359
+ /**
360
+ * This script removes a specific column from a table.
361
+ */
362
+ function main(workbook: ExcelScript.Workbook) {
363
+ // Get the table named "Inventory".
364
+ const table = workbook.getTable("Inventory");
365
+
366
+ // If it exists, remove the column named "Category".
367
+ let categoryColumn = table.getColumnByName("Category");
368
+ if (categoryColumn) {
369
+ categoryColumn.delete();
370
+ }
371
+ }
372
+ ```
273
373
- name : getColumns()
274
374
uid : ' ExcelScript!ExcelScript.Table#getColumns:member(1)'
275
375
package : ExcelScript!
@@ -809,4 +909,21 @@ methods:
809
909
type : boolean
810
910
return :
811
911
type : void
812
- description : ' '
912
+ description : |-
913
+
914
+
915
+ #### Examples
916
+
917
+ ```TypeScript
918
+ /**
919
+ * This script adds the Total Row to an existing table.
920
+ */
921
+ function main(workbook: ExcelScript.Workbook) {
922
+ // Get the first table in the current worksheet.
923
+ const selectedSheet = workbook.getActiveWorksheet();
924
+ const table = selectedSheet.getTables()[0];
925
+
926
+ // Set the Total Row to show.
927
+ table.setShowTotals(true);
928
+ }
929
+ ```
0 commit comments