Excel Undo feature is not working after saving data in customXmlParts
Closed this issue · 6 comments
Provide required information needed to triage your issue
The undo feature becomes non-functional after saving data in customXmlParts.
Your Environment
- Platform [PC desktop, Mac, iOS, Office on the web]: ______
- Host [Excel, Word, PowerPoint, etc.]: Excel
- Office version number: Microsoft 365 MSO (Version 2405 Build 16.0.17628.20006) 64-bit
- Operating System: Windows 10
- Browser (if using Office on the web): ______
Expected behavior
The Excel Undo feature should be working after saving data in customXmlParts
Current behavior
Changes made prior to creating customXmlParts cannot be undone.
Steps to reproduce
- Open Excel and enter a value into cell A1.
- Generate customXmlParts using the provided code using script lab.
- Attempt to undo the changes (Ctrl + Z). Note that the value in cell A1 cannot be reverted.
Code:
async function createCustomXmlPart() { await Excel.run(async (context) => { const originalXml = "<Reviewers><Reviewer>test</Reviewer></Reviewers>"; const customXmlPart = context.workbook.customXmlParts.add(originalXml); const xmlBlob = customXmlPart.getXml(); await context.sync(); console.log("xmlBlob.value:", xmlBlob.value); }); }
Context
I store some data in customXmlParts using an Excel add-in and retriev it upon opening the Excel file. But, any changes made to the excel workbook before creating customXmlParts cannot be undone.
Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.
Thank you for letting us know about this issue. We will take a look shortly. Thanks.
Hi @NiteshParmarCoh Thanks for reporting this issue. But when I copy your provided code using script lab, and click run button, nothing is happened. Could you please help to provide more details about code in order for us to better repro or investigation?
Please import the below code in the script lab.
description: ''
host: EXCEL
api_set: {}
script:
content: >
$("#create-custom-xml-part").on("click", () =>
tryCatch(createCustomXmlPart));
async function createCustomXmlPart() {
await Excel.run(async (context) => {
const originalXml = "<Reviewers><Reviewer>test</Reviewer></Reviewers>";
const customXmlPart = context.workbook.customXmlParts.add(originalXml);
const xmlBlob = customXmlPart.getXml();
await context.sync();
console.log("xmlBlob.value:", xmlBlob.value);
});
}
async function tryCatch(callback) {
try {
await callback();
} catch (error) {
console.error(error);
}
}
language: typescript
template:
content: "<section class=\"samples ms-font-m\">\n\t<button id=\"create-custom-xml-part\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Create XML part</span>\n </button>\n</section>"
language: html
style:
content: |
section.samples {
margin-top: 20px;
}
section.samples .ms-Button, section.setup .ms-Button {
display: block;
margin-bottom: 5px;
margin-left: 20px;
min-width: 80px;
}
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css
core-js@2.4.1/client/core.min.js
@types/core-js
jquery@3.1.1
@types/jquery@3.3.1
Hi @NiteshParmarCoh, Thanks for this details. I can repro this, the excel Api set operation can't redo/undo. It's a by-design behavior. Also please go to community to vote on undo support: Undo to help accelerate it! We value your feedback and will consider it in our future feature reviews.
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!
This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.