Sign Spreadsheet with Metadata

Introduction

In this tutorial, we’ll walk through the process of signing a spreadsheet with metadata using Groupdocs.Signature for .NET. Metadata signing allows you to embed additional information into your documents, providing context or verification. By the end of this guide, you’ll be able to apply metadata signatures to your spreadsheets effortlessly.

Prerequisites

Before we get started, ensure you have the following prerequisites:

  1. Groupdocs.Signature for .NET: Install the Groupdocs.Signature for .NET library. You can download it from here.
  2. .NET Environment: Make sure you have a .NET environment set up on your system.
  3. Spreadsheet Document: Have a sample spreadsheet document ready that you want to sign with metadata.

Import Namespaces

Before implementing the code, import the necessary namespaces to access the required classes and methods:

using System;
using System.IO;
using GroupDocs.Signature;
using GroupDocs.Signature.Domain;
using GroupDocs.Signature.Options;

Now, let’s break down the example code into multiple steps for a clearer understanding:

Step 1: Load the Spreadsheet Document

string filePath = "sample.xlsx";
string outputFilePath = Path.Combine("Your Document Directory", "SignSpreadsheetWithMetadata", "SignedWithMetadata.xlsx");
using (Signature signature = new Signature(filePath))
{

Step 2: Define Metadata Sign Options

	// create Metadata option with predefined Metadata text
	MetadataSignOptions options = new MetadataSignOptions();

Step 3: Create Metadata Signatures

	// Create few Spreadsheet Metadata signatures
	SpreadsheetMetadataSignature[] signatures = new SpreadsheetMetadataSignature[]
	{
		new SpreadsheetMetadataSignature("Author", "Mr.Scherlock Holmes"), // String value
		new SpreadsheetMetadataSignature("CreatedOn", DateTime.Now), // DateTime values
		new SpreadsheetMetadataSignature("DocumentId", 123456), // Integer value
		new SpreadsheetMetadataSignature("SignatureId", 123.456D), // Double value
		new SpreadsheetMetadataSignature("Amount", 123.456M), // Decimal value
		new SpreadsheetMetadataSignature("Total", 123.456F) // Float value
	};
	options.Signatures.AddRange(signatures);

Step 4: Sign the Document

	// sign document to file
	SignResult result = signature.Sign(outputFilePath, options);
	Console.WriteLine($"\nSource document signed successfully with {result.Succeeded.Count} signature(s).\nFile saved at {outputFilePath}.");
}

Conclusion

Congratulations! You’ve learned how to sign a spreadsheet with metadata using Groupdocs.Signature for .NET. Metadata signing enhances document integrity and provides additional information for verification purposes. Start applying metadata signatures to your spreadsheets today and ensure the authenticity and context of your documents.

FAQ’s

What is metadata signing?

Metadata signing involves embedding additional information, such as author name, creation date, or document ID, into a document for verification purposes.

Can I customize the metadata signatures?

Yes, you can customize metadata signatures according to your requirements, including text, dates, integers, doubles, decimals, and floats.

Is Groupdocs.Signature for .NET compatible with other document formats?

Yes, Groupdocs.Signature for .NET supports various document formats, including spreadsheets, presentations, PDFs, and more.

How can I verify metadata signatures?

You can verify metadata signatures using Groupdocs.Signature or other compatible software that supports metadata extraction.

Can I apply metadata signatures programmatically?

Yes, you can apply metadata signatures programmatically using the Groupdocs.Signature for .NET library within your .NET applications.