How to Preserve Sensitivity Labels in Excel Files Using Custom Applications
Question details
The user needs to learn how to retain Microsoft Information Protection (MIP) sensitivity labels when modifying and saving Excel files using a third-party application or spreadsheet control.

- Product
- Microsoft Excel / Microsoft Information Protection SDK
- Device & OS
- not provided
- Scenario
- Modifying an Excel file via a custom third-party application, which typically strips out metadata, requiring the developer to manually extract and restore security labels.
- Observed behavior
- When saving an Excel document via third-party controls, existing sensitivity labels are lost and must be programmatically read before editing and reapplied after saving.
Ensure you have the Microsoft Information Protection (MIP) SDK integrated into your development environment and that your organization possesses the required Azure Information Protection or Microsoft 365 licensing.
Use the Microsoft Information Protection (MIP) SDK
Programmatically extract the sensitivity labels from the file metadata before editing, and reapply them after the file is saved by your application.
Third-party spreadsheet controls often overwrite or strip custom metadata, including Microsoft Information Protection labels, during the save process. To prevent data leakage and maintain compliance, developers must use the MIP SDK to manually handle these labels.
Set up the Microsoft Information Protection SDK in your application. Configure the authentication delegate to connect with Azure Active Directory (Azure AD) and fetch the necessary policy engines.
Before modifying the Excel file, use the MIP SDK's File API to read the document's metadata. Extract the existing sensitivity label ID and store it in your application's memory.
Pass the Excel file to your third-party spreadsheet control. Perform the necessary data modifications and save the file to the disk or output stream as you normally would.
Once the file is saved, use the MIP SDK FileHandler to re-open the newly saved file. Apply the previously stored sensitivity label ID and commit the changes to restore the protection.

Manage and Secure Your Spreadsheets with WPS Office
If you are managing sensitive spreadsheets and need a reliable, cost-effective platform without complex custom SDK integrations, consider WPS Office. It provides powerful built-in document encryption and full compatibility with Microsoft Excel formats.
- 1. Download and Install WPS Office: Visit the official WPS website to download and install the free WPS Office suite on your device.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheets and open your .xlsx or .xls file to view and edit your data.
- 3. Apply Document Encryption: Go to the 'Menu' tab, select 'Document Encryption', and set a secure password to protect your sensitive spreadsheet data.

Frequently Asked Questions
What licenses are required to use the Microsoft Information Protection SDK?
Your application and users will require the appropriate information-protection infrastructure and licensing, such as Azure Information Protection (AIP) Premium or qualifying Microsoft 365 enterprise licenses.
Will third-party spreadsheet controls automatically preserve sensitivity labels?
No. Most third-party controls reconstruct the file upon saving, which strips out custom metadata like MIP sensitivity labels. You must programmatically extract and reapply them.
Does the MIP SDK support older Excel formats like .xls?
The MIP SDK is primarily designed to work with modern Office Open XML formats (.xlsx), which inherently support custom metadata and built-in labeling capabilities.
What happens if a sensitivity label is not reapplied after saving?
If the label is not reapplied, the saved document will lose its classification and applied protection policies. This can expose sensitive data to unauthorized users and violate organizational compliance rules.




