[Excel, PowerPoint, Word] Add TrackedObjects samples - #2594
Conversation
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
There was a problem hiding this comment.
Pull request overview
Adds new OfficeExtension.TrackedObjects code snippets to the shared Office snippets catalog, illustrating tracked-object usage patterns in Office.js scenarios (Excel + Word).
Changes:
- Added an
OfficeExtension.TrackedObjects:classsample intended to demonstrate releasing objects in an Excel loop. - Added
OfficeExtension.TrackedObjects#addand#removemember samples for Word proxy objects.
Comments suppressed due to low confidence (1)
docs/code-snippets/office-snippets.yaml:5287
- This loop calls
context.trackedObjects.remove(paragraph)for paragraphs that were never added/tracked. Per the API docs,removeis meant to release memory for objects that were previously added to the tracked objects collection; calling it on untracked objects can be incorrect and may fail at runtime.
// Release the paragraph proxy object from memory now that we're
// done with it. The memory is freed on the next context.sync() call.
context.trackedObjects.remove(paragraph);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // This sample inserts many ranges into an Excel worksheet, removing each | ||
| // cell proxy object from memory after it's used. |
| const cell = largeRange.getCell(i, j); | ||
| cell.values = [[i *j]]; | ||
|
|
||
| // Release the cell proxy object from memory now that we're | ||
| // done with it. The memory is freed on the next context.sync() call. | ||
| trackedObjects.remove(cell); |
|
Learn Build status updates of commit dee5f81: ✅ Validation status: passed
For more details, please refer to the build report. |
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit d1b410d: ✅ Validation status: passed
For more details, please refer to the build report. |
No description provided.