Home Ask Login Register

Developers Planet

Your answer is one click away!

Mikael Johansson February 2016

Clear a sheet in Excel 2013 with office add-ins

I have an office add-in that generates a report (tables). The second time the user is running it I want to clear that sheet.

I have been trying around and have read through the documentation but I cant find a way to do this.

Have anyone found a solution to solve something like this?


Michael Zlatkovsky February 2016

Use sheet.getRange().clear() method.


Excel.run(function (ctx) {
    var sheet = ctx.workbook.worksheets.getActiveWorksheet();
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));

~ Michael Zlatkovsky, developer on Office Extensibility team, MSFT

Post Status

Asked in February 2016
Viewed 2,052 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life