Currently I'm triying to find a solution that helps me to storage the content of the worksheets in some place like localstorage for example.
async backupSheets() {
await Excel.run(async (context) => {
var worksheets = context.workbook.worksheets;
worksheets.load('items');
await context.sync();
let wsBackup = worksheets;
for (var i = 0; i < worksheets.items.length; i++) {
console.log(worksheets.items[i].toJSON());
worksheets.items[i].delete();
}
//There will be some code to restore the workshets currently with:
worksheets = wsBackup;
//But it doesn't works.
await context.sync();
});
}
The expected behavior is when I do the assigment worksheets = wsBackup
it restore the worksheets that I saved before the delete loop.
Currently this isn't working and I'm triying to find a workaround for this.
An Excel scenario should be..
- Copy all the worksheets in a variable called
wsBackup
- Delete all worksheets except the last
- The proxy object that I used for it should be restored with the assigment of the backup
wsBackup
- The worksheets should be restored properly in the workbook
The actual behavior that I got is all the steps except the restored worksheets.