Dermot
1
If I were using OpenXml, I could set document properties by:
private static void SetPackageProperties(OpenXmlPackage document)
{
document.PackageProperties.Creator = "Titus Pullo";
document.PackageProperties.Title = "Super Report 2021";
document.PackageProperties.Subject = "Evaluation";
document.PackageProperties.Category = "Gembox";
document.PackageProperties.LastModifiedBy = "Titus Pullo";
}
How can I do this with GemBox.Spreadsheet (and GemBox.Document)?
Hi Dermot,
Here is how you can set those properties with GemBox.Spreadsheet:
var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sheet 1");
worksheet.Cells["A1"].Value = "Sample spreadsheet.";
var spreadsheetProperties = workbook.DocumentProperties;
spreadsheetProperties.BuiltIn.Add(BuiltInDocumentProperties.Author, "Titus Pullo");
spreadsheetProperties.BuiltIn.Add(BuiltInDocumentProperties.Title, "Super Report 2021");
spreadsheetProperties.BuiltIn.Add(BuiltInDocumentProperties.Subject, "Evaluation");
spreadsheetProperties.BuiltIn.Add(BuiltInDocumentProperties.Category, "Gembox");
spreadsheetProperties.BuiltIn.Add(BuiltInDocumentProperties.LastSavedBy, "Titus Pullo");
workbook.Save("sample.xlsx");
And here is how you can do that with GemBox.Document:
var document = new DocumentModel();
document.Sections.Add(
new Section(document,
new Paragraph(document, "Sample document.")));
var documentProperties = document.DocumentProperties;
documentProperties.BuiltIn.Add(BuiltInDocumentProperty.Author, "Titus Pullo");
documentProperties.BuiltIn.Add(BuiltInDocumentProperty.Title, "Super Report 2021");
documentProperties.BuiltIn.Add(BuiltInDocumentProperty.Subject, "Evaluation");
documentProperties.BuiltIn.Add(BuiltInDocumentProperty.Category, "Gembox");
documentProperties.BuiltIn.Add(BuiltInDocumentProperty.LastSavedBy, "Titus Pullo");
document.Save("sample.docx");
Also, please check Excel Document Properties and Word Document Properties examples.
I hope this helps.
Regards,
Mario