DEV Community

Shahzad Ashraf
Shahzad Ashraf

Posted on

Remove Sensitive Metadata from Excel Files Programmatically in .NET

Eliminating concealed metadata from Excel spreadsheets is essential for safeguarding sensitive business data and upholding data privacy. With the GroupDocs.Metadata Cloud .NET SDK, developers can streamline the process of identifying and erasing metadata from XLSX files effortlessly. There's no need for manual intervention—just a few lines of code utilizing a powerful .NET REST API can sanitize Excel files before distribution, storage, or publication.

This formidable Cloud SDK for .NET facilitates the accurate removal of document properties, custom metadata attributes, built-in tags, and other embedded information that could unintentionally reveal internal information. By incorporating metadata removal into your workflow, you not only enhance compliance but also guarantee that your applications actively and consistently manage document security.

Ideal for document automation, legal technology, enterprise solutions, and internal applications, this API-driven tool enables you to improve your control over Excel file metadata. Elevate your application’s reliability and performance by integrating dependable, cloud-based XLSX metadata sanitization in .NET—using a lightweight, developer-friendly API. To begin, please refer to our comprehensive step-by-step guide today!

The following C# code snippet illustrates how this functionality operates within .NET applications:

using GroupDocs.Metadata.Cloud.Sdk.Api;
using GroupDocs.Metadata.Cloud.Sdk.Client;
using GroupDocs.Metadata.Cloud.Sdk.Model;
using GroupDocs.Metadata.Cloud.Sdk.Model.Requests;

class Program
{
    static void Main(string[] args)
    {

        // Step 1: Set up API credentials and initialize configuration
        string MyAppKey = "your-app-key";
        string MyAppSecret = "your-app-secret";
        var configuration = new Configuration(MyAppKey, MyAppSecret);

        // Step 2: Initialize Metadata API for removing metadata
        var metadataApi = new MetadataApi(configuration);

        // Step 3: Set up the file info with the path of 
        // the source XLSX file in cloud storage
        var fileInfo = new GroupDocs.Metadata.Cloud.Sdk.Model.FileInfo
        {
            FilePath = "SampleFiles/source.xlsx"
        };

        // Step 4: Create metadata remove options with search criteria
        var removeOptions = new RemoveOptions
        {
            FileInfo = fileInfo,
            SearchCriteria = new SearchCriteria
            {
                NameOptions = new NameOptions
                {
                    // Specify the property you want to remove
                    Value = "Title"
                }
            }
        };

        // Step 5: Create and execute the request to remove the metadata
        var removeRequest = new RemoveRequest(removeOptions);
        var response = metadataApi.Remove(removeRequest);

        // Step 6: Display the removal result
        Console.WriteLine("No. of properties removed: " + response.RemovedCount);
        Console.WriteLine("Updated file: " + response.Path);
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

OSZAR »