Skip to content

[Excel, PowerPoint, Word] Add TrackedObjects samples - #2594

Open
AlexJerabek wants to merge 2 commits into
mainfrom
AlexJ-TrackedObjects
Open

[Excel, PowerPoint, Word] Add TrackedObjects samples#2594
AlexJerabek wants to merge 2 commits into
mainfrom
AlexJ-TrackedObjects

Conversation

@AlexJerabek

Copy link
Copy Markdown
Contributor

No description provided.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:class sample intended to demonstrate releasing objects in an Excel loop.
  • Added OfficeExtension.TrackedObjects#add and #remove member 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, remove is 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.

Comment thread docs/code-snippets/office-snippets.yaml Outdated
Comment on lines +5229 to +5230
// This sample inserts many ranges into an Excel worksheet, removing each
// cell proxy object from memory after it's used.
Comment on lines +5240 to +5245
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-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit dee5f81:

✅ Validation status: passed

File Status Preview URL Details
docs/code-snippets/office-snippets.yaml ✅Succeeded

For more details, please refer to the build report.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit d1b410d:

✅ Validation status: passed

File Status Preview URL Details
docs/code-snippets/office-snippets.yaml ✅Succeeded

For more details, please refer to the build report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants