In a previous post, I showed you how to remove comments from a Word file. In today's post, I am going to show you how to accomplish the same scenario, but this time with Excel and PowerPoint files. Excel and PowerPoint have a Document Inspector feature, which is able to remove multiple types of data/content, including comments. This feature works great for client side solutions, but how do you cleanse these files of comments on the server? The Open XML SDK can accomplish these scenarios in just a few lines of code.
Note: The code showed in this post is backwards compatible with version 1 of the SDK.
Imagine I start off with a PowerPoint deck that has multiple slides and comments. Here is a screenshot of a comment within a PowerPoint slide:
To remove comments from a PowerPoint deck we need to take the following actions:
If you want to jump straight into the code, feel free to download this solution here.
The code is pretty easy and maps 1:1 to the steps I mentioned above:
Running this method, I end up with a presentation void of comments. Pretty easy!
Here is a screenshot of the final presentation:
This solution is very similar to the PowerPoint solution.
Imagine I start off with an Excel workbook that has multiple worksheets, where each worksheet contains multiple comments. Here is a screenshot of a comment within a worksheet cell:
To remove comments from an Excel workbook we need to take the following actions:
This code is very similar to the code used to remove comments from a PowerPoint deck:
Running this method, I end up with a workbook void of comments.
Here is a screenshot of the final workbook:
Zeyad Rajabi