Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fileformat-cells-gists/65f165dc2d09e35222991eb175894119 to your computer and use it in GitHub Desktop.
Save fileformat-cells-gists/65f165dc2d09e35222991eb175894119 to your computer and use it in GitHub Desktop.
Set Document Properties to a Workbook in C#
// Create a new workbook and set cell values and document properties.
using (var workbook = new Workbook())
{
// Access the first worksheet.
Worksheet firstSheet = workbook.Worksheets[0];
// Set values for cells A1 and A2.
Cell cellA1 = firstSheet.Cells["A1"];
cellA1.PutValue("Text A1");
Cell cellA2 = firstSheet.Cells["A2"];
cellA2.PutValue("Text A2");
// Configure document properties.
var newProperties = new BuiltInDocumentProperties
{
Author = "Fahad Adeel",
Title = "Sample Workbook",
CreatedDate = DateTime.Now,
ModifiedBy = "Fahad",
ModifiedDate = DateTime.Now.AddHours(1),
Subject = "Testing Subject"
};
// Assign the new properties to the workbook.
workbook.BuiltinDocumentProperties = newProperties;
// Save the workbook to the specified path.
workbook.Save(filePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment