Hi!
Thank you for your message!
As I wrote earlier, I prepare a plugin and use document builder to manipulate the sheet. In the Asc.scope.plots array I have previously made plots using Google Charts, which are converted to Base64 encoded images.
function pushCharts() {
window.Asc.plugin.callCommand( function () {
//adding new ApiImage's...
let sheet = Api.GetSheet(Asc.scope.sheet);
for (let i=0; i<Asc.scope.plots.length; i++) {
let plot = Asc.scope.plots[i];
sheet.AddImage(plot, 120*36000, 90*36000, i+1, 20*36000, i+1, 20*36000);
}
}, false, true);
}
Now I would like to add code to this function that will allow me to delete existing images before adding new, current ones.
function deleteOldAndPushCharts() {
window.Asc.plugin.callCommand( function () {
let sheet = Api.GetSheet(Asc.scope.sheet);
//delete all old ApiImage's
????
//adding new ApiImage's...
for (let i=0; i<Asc.scope.plots.length; i++) {
let plot = Asc.scope.plots[i];
sheet.AddImage(plot, 120*36000, 90*36000, i+1, 20*36000, i+1, 20*36000);
}
}, false, true);
}
Thank you in advance for your help!
greetings Piotr
Unfortunately, direct method to remove images from worksheet does not exist. I think you can directly replace those images with ReplaceCurrentImage method. However, you will have to manually select every image before replacing it.
Alternative solution is to ‘re-create’ a sheet without images and then insert new ones. An example is:
Note: as of now I’d recommend to avoid using Delete() on original sheet before making sure that data is copied correctly. You can create a copy of original sheet with images to run tests with it or comment out this line until proper result is achieved.
In version 8.1 various changes will be made to overall work with sheets that will improve interactions with certain methods, including Delete().
Currently estimated date of release is summer of this year.
Please note that these questions are not related to the topic of this thread. Please create a separate thread to avoid mixing up different topics in one thread.