From de63e3c00ee160de206dbd6c2b08b9d0b74063b8 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:42:59 +0500 Subject: [PATCH 01/47] Add example: load-a-workbook-and-retrieve-the-title-builtin-property-for-verification --- document-properties/agents.md | 57 +++++++++++++++++++ ...title-builtin-property-for-verification.cs | 34 +++++++++++ 2 files changed, 91 insertions(+) create mode 100644 document-properties/agents.md create mode 100644 document-properties/load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs diff --git a/document-properties/agents.md b/document-properties/agents.md new file mode 100644 index 0000000000..ac00ea7ff3 --- /dev/null +++ b/document-properties/agents.md @@ -0,0 +1,57 @@ +# Document Properties Examples + +This folder contains **Aspose.Cells for .NET** code examples related to: + +Document Properties + + +## Purpose + +These examples demonstrate common **Aspose.Cells APIs** used when working with: + +- Workbooks +- Worksheets +- Cells +- Formulas +- Charts +- Data operations + + +## Example Files + +Each `.cs` file demonstrates a specific task related to **Document Properties**. + +Example: + +create-a-workbook.cs + + +## Required Namespaces + +Most examples will require: + +using Aspose.Cells; + + +## Common Pattern + +Typical Aspose.Cells workflow: + +Workbook workbook = new Workbook(); + +Worksheet sheet = workbook.Worksheets[0]; + +Cells cells = sheet.Cells; + + +## Output + +Examples may generate: + +- XLSX files +- PDF files +- CSV files +- Images + +Output files are written to the working directory. +- load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs diff --git a/document-properties/load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs b/document-properties/load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs new file mode 100644 index 0000000000..834d574776 --- /dev/null +++ b/document-properties/load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs @@ -0,0 +1,34 @@ +using System; +using Aspose.Cells; + +namespace AsposeCellsBuiltInPropertyDemo +{ + class Program + { + static void Main() + { + // Define the file path for the workbook + string filePath = "BuiltInTitleDemo.xlsx"; + + // ------------------------------------------------- + // Create a new workbook and set the Title property + // ------------------------------------------------- + Workbook workbook = new Workbook(); // create a new workbook + workbook.BuiltInDocumentProperties.Title = "Sample Document Title"; // set Title + + // Save the workbook to disk + workbook.Save(filePath, SaveFormat.Xlsx); + + // ------------------------------------------------- + // Load the workbook from the saved file + // ------------------------------------------------- + Workbook loadedWorkbook = new Workbook(filePath); // load the workbook + + // Retrieve the Title built‑in property for verification + string retrievedTitle = loadedWorkbook.BuiltInDocumentProperties.Title; + + // Output the retrieved Title to the console + Console.WriteLine("Retrieved Title: " + retrievedTitle); + } + } +} \ No newline at end of file From 8a38f25d48eaacc426f3ac77749b6c0db7a264be Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:43:43 +0500 Subject: [PATCH 02/47] Add example: open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator --- document-properties/agents.md | 1 + ...builtin-property-to-identify-the-creator.cs | 18 ++++++++++++++++++ index.json | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 document-properties/open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index ac00ea7ff3..788775a1c3 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -55,3 +55,4 @@ Examples may generate: Output files are written to the working directory. - load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs +- open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs diff --git a/document-properties/open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs b/document-properties/open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs new file mode 100644 index 0000000000..e2f34cad44 --- /dev/null +++ b/document-properties/open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs @@ -0,0 +1,18 @@ +using System; +using Aspose.Cells; + +class Program +{ + static void Main() + { + // Load the Excel file + string filePath = "input.xlsx"; + Workbook workbook = new Workbook(filePath); + + // Retrieve the built‑in Author property + string author = workbook.BuiltInDocumentProperties.Author; + + // Output the author name + Console.WriteLine("Author: " + author); + } +} \ No newline at end of file diff --git a/index.json b/index.json index a01adc94a2..1b18881c0a 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", "title": "Load a workbook and retrieve the Title built\u2011in property for verification." }, + { + "category": "document-properties", + "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", + "title": "Open an Excel file and read the Author built\u2011in property to identify the creator." + }, { "category": "save-workbook", "file": "create-a-workbook-populate-data-programmatically-and-export-it-as-a-tabdelimited-txt-file.cs", From b23219cdb5ff6466080188061896ab8da674b077 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:44:27 +0500 Subject: [PATCH 03/47] Add example: instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information --- document-properties/agents.md | 1 + ...n-property-to-check-version-information.cs | 23 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 29 insertions(+) create mode 100644 document-properties/instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 788775a1c3..98233276b2 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -56,3 +56,4 @@ Examples may generate: Output files are written to the working directory. - load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs - open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs +- instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs diff --git a/document-properties/instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs b/document-properties/instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs new file mode 100644 index 0000000000..6c6457753f --- /dev/null +++ b/document-properties/instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs @@ -0,0 +1,23 @@ +using System; +using Aspose.Cells; + +class Program +{ + static void Main() + { + // Create a new workbook instance + Workbook workbook = new Workbook(); + + // Set the built‑in DocumentVersion property (optional) + workbook.BuiltInDocumentProperties.DocumentVersion = "1.0"; + + // Retrieve the DocumentVersion property value + string docVersion = workbook.BuiltInDocumentProperties.DocumentVersion; + + // Output the version information + Console.WriteLine("Document Version: " + docVersion); + + // Save the workbook to demonstrate the full lifecycle + workbook.Save("DocumentVersionDemo.xlsx", SaveFormat.Xlsx); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 1b18881c0a..4fe34d8b65 100644 --- a/index.json +++ b/index.json @@ -129,6 +129,11 @@ "file": "update-the-text-direction-of-all-comments-in-a-worksheet-to-lefttoright-for-standard-layout.cs", "title": "Update the text direction of all comments in a worksheet to LeftToRight for standard layout." }, + { + "category": "document-properties", + "file": "instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs", + "title": "Instantiate a workbook and obtain the DocumentVersion built\u2011in property to check version information." + }, { "category": "document-properties", "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", From 2acd493330c0516115dfc82201baed98da7fa481 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:45:29 +0500 Subject: [PATCH 04/47] Add example: load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings --- document-properties/agents.md | 1 + ...n-property-to-determine-locale-settings.cs | 52 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 58 insertions(+) create mode 100644 document-properties/load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 98233276b2..5d5aa15ee6 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -57,3 +57,4 @@ Output files are written to the working directory. - load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs - open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs - instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs +- load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs diff --git a/document-properties/load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs b/document-properties/load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs new file mode 100644 index 0000000000..2c0fd3bd9a --- /dev/null +++ b/document-properties/load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs @@ -0,0 +1,52 @@ +using System; +using System.IO; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsExamples +{ + public class ReadBuiltInLanguageProperty + { + // Entry point for the application + public static void Main(string[] args) + { + Run(); + } + + public static void Run() + { + // Path to the Excel file to be loaded + string filePath = "sample.xlsx"; + + // Verify that the file exists to avoid FileNotFoundException + if (!File.Exists(filePath)) + { + Console.WriteLine($"File not found: {filePath}"); + return; + } + + try + { + // Create LoadOptions using the default constructor + LoadOptions loadOptions = new LoadOptions(); + + // Load the workbook with the specified LoadOptions + Workbook workbook = new Workbook(filePath, loadOptions); + + // Access the built‑in document properties collection + BuiltInDocumentPropertyCollection builtInProps = workbook.BuiltInDocumentProperties; + + // Read the Language property which indicates the locale settings of the file + string language = builtInProps.Language; + + // Output the language value + Console.WriteLine($"Built‑in Language property: {language}"); + } + catch (Exception ex) + { + // Handle any runtime errors gracefully + Console.WriteLine($"An error occurred: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 4fe34d8b65..f554314aca 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs", "title": "Instantiate a workbook and obtain the DocumentVersion built\u2011in property to check version information." }, + { + "category": "document-properties", + "file": "load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs", + "title": "Load a spreadsheet and read the Language built\u2011in property to determine locale settings." + }, { "category": "document-properties", "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", From 0d019023c77f6472c0f8193cb9bdd0938139a6e5 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:46:38 +0500 Subject: [PATCH 05/47] Add example: open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag --- document-properties/agents.md | 1 + ...tin-property-to-view-image-scaling-flag.cs | 45 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 51 insertions(+) create mode 100644 document-properties/open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 5d5aa15ee6..3233cdaa66 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -58,3 +58,4 @@ Output files are written to the working directory. - open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs - instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs - load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs +- open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs diff --git a/document-properties/open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs b/document-properties/open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs new file mode 100644 index 0000000000..0454682691 --- /dev/null +++ b/document-properties/open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs @@ -0,0 +1,45 @@ +using System; +using System.IO; +using Aspose.Cells; + +namespace AsposeCellsExamples +{ + public class BuiltInDocumentPropertyScaleCropDemo + { + public static void Main() + { + Run(); + } + + public static void Run() + { + try + { + string filePath = "input.xlsx"; + + // Prevent FileNotFoundException + if (!File.Exists(filePath)) + { + Console.WriteLine($"File not found: {filePath}"); + return; + } + + // Load the workbook + Workbook workbook = new Workbook(filePath); + + // Access built‑in document properties + var properties = workbook.BuiltInDocumentProperties; + + // Get the ScaleCrop property (true = thumbnail is scaled, false = original size) + bool scaleCrop = properties.ScaleCrop; + + // Display the value + Console.WriteLine("ScaleCrop property value: " + scaleCrop); + } + catch (Exception ex) + { + Console.WriteLine("An error occurred: " + ex.Message); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index f554314aca..b902e52afb 100644 --- a/index.json +++ b/index.json @@ -144,6 +144,11 @@ "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", "title": "Load a workbook and retrieve the Title built\u2011in property for verification." }, + { + "category": "document-properties", + "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", + "title": "Open a workbook and query the ScaleCrop built\u2011in property to view image scaling flag." + }, { "category": "document-properties", "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", From 49e6d3146eb5d4cce83d3a5300b6ae303fbc2877 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:47:20 +0500 Subject: [PATCH 06/47] Add example: load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status --- document-properties/agents.md | 1 + ...e-builtin-property-for-hyperlink-status.cs | 21 +++++++++++++++++++ index.json | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 document-properties/load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 3233cdaa66..43a1adc30a 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -59,3 +59,4 @@ Output files are written to the working directory. - instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs - load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs - open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs +- load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs diff --git a/document-properties/load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs b/document-properties/load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs new file mode 100644 index 0000000000..35316519b1 --- /dev/null +++ b/document-properties/load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs @@ -0,0 +1,21 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class InspectLinksUpToDate +{ + static void Main() + { + // Load an existing Excel workbook + Workbook workbook = new Workbook("input.xlsx"); + + // Access the built‑in document properties collection + BuiltInDocumentPropertyCollection builtInProps = workbook.BuiltInDocumentProperties; + + // Retrieve the LinksUpToDate property which indicates if hyperlinks are current + bool linksAreUpToDate = builtInProps.LinksUpToDate; + + // Output the status to the console + Console.WriteLine("Hyperlinks up‑to‑date: " + linksAreUpToDate); + } +} \ No newline at end of file diff --git a/index.json b/index.json index b902e52afb..a5c6635d94 100644 --- a/index.json +++ b/index.json @@ -144,6 +144,11 @@ "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", "title": "Load a workbook and retrieve the Title built\u2011in property for verification." }, + { + "category": "document-properties", + "file": "load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs", + "title": "Load an Excel document and inspect the LinksUpToDate built\u2011in property for hyperlink status." + }, { "category": "document-properties", "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", From 51df1a0b383966a22866be1b5942de75c4e02b9d Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:48:05 +0500 Subject: [PATCH 07/47] Add example: create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name --- document-properties/agents.md | 1 + ...-property-to-a-descriptive-project-name.cs | 26 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 32 insertions(+) create mode 100644 document-properties/create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 43a1adc30a..a96b5e8c72 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -60,3 +60,4 @@ Output files are written to the working directory. - load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs - open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs - load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs +- create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs diff --git a/document-properties/create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs b/document-properties/create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs new file mode 100644 index 0000000000..ec7f4d7e9a --- /dev/null +++ b/document-properties/create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs @@ -0,0 +1,26 @@ +using System; +using Aspose.Cells; + +namespace AsposeCellsTitleDemo +{ + class Program + { + static void Main() + { + // Create a new workbook (uses the Workbook constructor - lifecycle create rule) + Workbook workbook = new Workbook(); + + // Set the built‑in Title property to a descriptive project name + workbook.BuiltInDocumentProperties.Title = "Project XYZ - Financial Report"; + + // Optionally display the title to verify + Console.WriteLine("Workbook Title: " + workbook.BuiltInDocumentProperties.Title); + + // Save the workbook to a file (uses the Save method - lifecycle save rule) + string outputPath = "ProjectXYZ_Report.xlsx"; + workbook.Save(outputPath, SaveFormat.Xlsx); + + Console.WriteLine("Workbook saved to: " + outputPath); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index a5c6635d94..4068218b2a 100644 --- a/index.json +++ b/index.json @@ -129,6 +129,11 @@ "file": "update-the-text-direction-of-all-comments-in-a-worksheet-to-lefttoright-for-standard-layout.cs", "title": "Update the text direction of all comments in a worksheet to LeftToRight for standard layout." }, + { + "category": "document-properties", + "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", + "title": "Create a workbook and set the Title built\u2011in property to a descriptive project name." + }, { "category": "document-properties", "file": "instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs", From 308c0074e9f1e375713fd7a1b080c1a1deeea186 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:48:43 +0500 Subject: [PATCH 08/47] Add example: open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier --- document-properties/agents.md | 1 + ...with-the-correct-contributor-identifier.cs | 27 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 33 insertions(+) create mode 100644 document-properties/open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index a96b5e8c72..b4b6041e6e 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -61,3 +61,4 @@ Output files are written to the working directory. - open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs - load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs - create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs +- open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs diff --git a/document-properties/open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs b/document-properties/open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs new file mode 100644 index 0000000000..1bccaa301d --- /dev/null +++ b/document-properties/open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs @@ -0,0 +1,27 @@ +using System; +using Aspose.Cells; + +namespace UpdateAuthorProperty +{ + class Program + { + static void Main(string[] args) + { + // Path to the existing workbook + string inputPath = "input.xlsx"; + + // Load the workbook from the file + Workbook workbook = new Workbook(inputPath); + + // Update the built‑in Author property with the contributor identifier + string contributorId = "Contributor_12345"; + workbook.BuiltInDocumentProperties.Author = contributorId; + + // Save the workbook back (overwrites the original file or specify a new path) + string outputPath = "output.xlsx"; + workbook.Save(outputPath); + + Console.WriteLine($"Author property updated to '{contributorId}' and saved to '{outputPath}'."); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 4068218b2a..5f6c23d885 100644 --- a/index.json +++ b/index.json @@ -154,6 +154,11 @@ "file": "load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs", "title": "Load an Excel document and inspect the LinksUpToDate built\u2011in property for hyperlink status." }, + { + "category": "document-properties", + "file": "open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs", + "title": "Open a file and update the Author built\u2011in property with the correct contributor identifier." + }, { "category": "document-properties", "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", From 6d47bd1c6033293974bd80f48d482a63f7a07181 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:49:21 +0500 Subject: [PATCH 09/47] Add example: load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20 --- document-properties/agents.md | 1 + ...ntversion-builtin-property-the-value-20.cs | 26 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 32 insertions(+) create mode 100644 document-properties/load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index b4b6041e6e..35bff6c37c 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -62,3 +62,4 @@ Output files are written to the working directory. - load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs - create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs - open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs +- load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs diff --git a/document-properties/load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs b/document-properties/load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs new file mode 100644 index 0000000000..2cb4d7823f --- /dev/null +++ b/document-properties/load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs @@ -0,0 +1,26 @@ +using System; +using Aspose.Cells; + +namespace AsposeCellsDocumentVersionDemo +{ + class Program + { + static void Main() + { + // Path to the existing workbook to be loaded + string inputPath = "input.xlsx"; + + // Load the workbook from the file system + Workbook workbook = new Workbook(inputPath); + + // Set the built‑in DocumentVersion property to "2.0" + workbook.BuiltInDocumentProperties.DocumentVersion = "2.0"; + + // Save the modified workbook to a new file + string outputPath = "output.xlsx"; + workbook.Save(outputPath, SaveFormat.Xlsx); + + Console.WriteLine($"DocumentVersion set to \"2.0\" and saved to {outputPath}"); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 5f6c23d885..e14ed923f1 100644 --- a/index.json +++ b/index.json @@ -144,6 +144,11 @@ "file": "load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs", "title": "Load a spreadsheet and read the Language built\u2011in property to determine locale settings." }, + { + "category": "document-properties", + "file": "load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs", + "title": "Load a workbook and assign the DocumentVersion built\u2011in property the value \"2.0\"." + }, { "category": "document-properties", "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", From c32bc639507f13a8bc61482a65b847857e37cf91 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:50:05 +0500 Subject: [PATCH 10/47] Add example: open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization --- document-properties/agents.md | 1 + ...ltin-property-to-fr-fr-for-localization.cs | 26 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 32 insertions(+) create mode 100644 document-properties/open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 35bff6c37c..df4f17e121 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -63,3 +63,4 @@ Output files are written to the working directory. - create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs - open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs - load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs +- open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs diff --git a/document-properties/open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs b/document-properties/open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs new file mode 100644 index 0000000000..8bab4c501b --- /dev/null +++ b/document-properties/open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs @@ -0,0 +1,26 @@ +using System; +using Aspose.Cells; + +namespace AsposeCellsLanguageDemo +{ + class Program + { + static void Main(string[] args) + { + // Path to the existing spreadsheet + string inputPath = "input.xlsx"; + + // Load the workbook (uses Aspose.Cells default load options) + Workbook workbook = new Workbook(inputPath); + + // Set the built‑in Language property to French (France) + workbook.BuiltInDocumentProperties.Language = "fr-FR"; + + // Save the modified workbook + string outputPath = "output.xlsx"; + workbook.Save(outputPath); + + Console.WriteLine($"Language property set to 'fr-FR' and workbook saved to '{outputPath}'."); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index e14ed923f1..1eb868596f 100644 --- a/index.json +++ b/index.json @@ -164,6 +164,11 @@ "file": "open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs", "title": "Open a file and update the Author built\u2011in property with the correct contributor identifier." }, + { + "category": "document-properties", + "file": "open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs", + "title": "Open a spreadsheet and set the Language built\u2011in property to \"fr-FR\" for localization." + }, { "category": "document-properties", "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", From 1086d294e5043d9ed7018191d16288693e75ca65 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:50:41 +0500 Subject: [PATCH 11/47] Add example: instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions --- document-properties/agents.md | 1 + ...-property-to-preserve-image-proportions.cs | 24 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 30 insertions(+) create mode 100644 document-properties/instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index df4f17e121..2fdfe82fa0 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -64,3 +64,4 @@ Output files are written to the working directory. - open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs - load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs - open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs +- instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs diff --git a/document-properties/instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs b/document-properties/instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs new file mode 100644 index 0000000000..d403cd87bc --- /dev/null +++ b/document-properties/instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs @@ -0,0 +1,24 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class ScaleCropDemo +{ + static void Main() + { + // Create a new workbook instance + Workbook workbook = new Workbook(); + + // Access the built‑in document properties collection + BuiltInDocumentPropertyCollection properties = workbook.BuiltInDocumentProperties; + + // Enable ScaleCrop to preserve image proportions in the thumbnail + properties.ScaleCrop = true; + + // Output the current value to verify + Console.WriteLine("ScaleCrop property value: " + properties.ScaleCrop); + + // Save the workbook to a file (XLSX format) + workbook.Save("output.xlsx", SaveFormat.Xlsx); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 1eb868596f..817f52ceda 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", "title": "Create a workbook and set the Title built\u2011in property to a descriptive project name." }, + { + "category": "document-properties", + "file": "instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs", + "title": "Instantiate a workbook and enable the ScaleCrop built\u2011in property to preserve image proportions." + }, { "category": "document-properties", "file": "instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs", From 520fe73c85f0eefe6c67872e57ef0dea3fda289e Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:51:19 +0500 Subject: [PATCH 12/47] Add example: load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks --- document-properties/agents.md | 1 + ...e-builtin-property-to-prevent-link-checks.cs | 17 +++++++++++++++++ index.json | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 document-properties/load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 2fdfe82fa0..241750e523 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -65,3 +65,4 @@ Output files are written to the working directory. - load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs - open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs - instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs +- load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs diff --git a/document-properties/load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs b/document-properties/load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs new file mode 100644 index 0000000000..db2d65a037 --- /dev/null +++ b/document-properties/load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs @@ -0,0 +1,17 @@ +using System; +using Aspose.Cells; + +class Program +{ + static void Main() + { + // Load the workbook from a file + Workbook workbook = new Workbook("input.xlsx"); + + // Disable the LinksUpToDate built‑in property to prevent link checks + workbook.BuiltInDocumentProperties.LinksUpToDate = false; + + // Save the workbook with the updated setting + workbook.Save("output.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 817f52ceda..b2f29c49d1 100644 --- a/index.json +++ b/index.json @@ -154,6 +154,11 @@ "file": "load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs", "title": "Load a workbook and assign the DocumentVersion built\u2011in property the value \"2.0\"." }, + { + "category": "document-properties", + "file": "load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs", + "title": "Load a workbook and disable the LinksUpToDate built\u2011in property to prevent link checks." + }, { "category": "document-properties", "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", From b2110d4d487a8d8121a5a7d4c5d0fc6f71ca7fb1 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:52:00 +0500 Subject: [PATCH 13/47] Add example: open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value --- document-properties/agents.md | 1 + ...sseddate-with-the-current-datetime-value.cs | 18 ++++++++++++++++++ index.json | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 document-properties/open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 241750e523..2a10eb0aaf 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -66,3 +66,4 @@ Output files are written to the working directory. - open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs - instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs - load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs +- open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs diff --git a/document-properties/open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs b/document-properties/open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs new file mode 100644 index 0000000000..0ac7c77e1a --- /dev/null +++ b/document-properties/open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs @@ -0,0 +1,18 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Create a new workbook (or you could load an existing one) + Workbook workbook = new Workbook(); + + // Add a custom document property named "ProcessedDate" with the current date and time + workbook.CustomDocumentProperties.Add("ProcessedDate", DateTime.Now); + + // Save the workbook to a file + workbook.Save("ProcessedWorkbook.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index b2f29c49d1..60e18792a8 100644 --- a/index.json +++ b/index.json @@ -179,6 +179,11 @@ "file": "open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs", "title": "Open a spreadsheet and set the Language built\u2011in property to \"fr-FR\" for localization." }, + { + "category": "document-properties", + "file": "open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs", + "title": "Open a workbook and add a custom property \"ProcessedDate\" with the current DateTime value." + }, { "category": "document-properties", "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", From c9e47d3c0cfeb83355afb7e4d61c65e4d7c73692 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:52:39 +0500 Subject: [PATCH 14/47] Add example: load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier --- document-properties/agents.md | 1 + ...ty-projectid-with-an-integer-identifier.cs | 20 +++++++++++++++++++ index.json | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 document-properties/load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 2a10eb0aaf..94dd394206 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -67,3 +67,4 @@ Output files are written to the working directory. - instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs - load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs - open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs +- load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs diff --git a/document-properties/load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs b/document-properties/load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs new file mode 100644 index 0000000000..d6d2f27ebb --- /dev/null +++ b/document-properties/load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs @@ -0,0 +1,20 @@ +using System; +using Aspose.Cells; + +class Program +{ + static void Main() + { + // Load the existing Excel file + string inputPath = "input.xlsx"; + Workbook workbook = new Workbook(inputPath); + + // Add a custom document property named "ProjectId" with an integer value + int projectId = 12345; // example identifier + workbook.CustomDocumentProperties.Add("ProjectId", projectId); + + // Save the workbook with the new property + string outputPath = "output.xlsx"; + workbook.Save(outputPath, SaveFormat.Xlsx); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 60e18792a8..d17ec630f9 100644 --- a/index.json +++ b/index.json @@ -169,6 +169,11 @@ "file": "load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs", "title": "Load an Excel document and inspect the LinksUpToDate built\u2011in property for hyperlink status." }, + { + "category": "document-properties", + "file": "load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs", + "title": "Load an Excel file and create a custom property \"ProjectId\" with an integer identifier." + }, { "category": "document-properties", "file": "open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs", From 8c31f2e391dca87d6a935d1fdaa7048ab076aacb Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:53:17 +0500 Subject: [PATCH 15/47] Add example: open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true --- document-properties/agents.md | 1 + ...-boolean-property-isreviewed-set-to-true.cs | 18 ++++++++++++++++++ index.json | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 document-properties/open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 94dd394206..4aff8b3e8b 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -68,3 +68,4 @@ Output files are written to the working directory. - load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs - open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs - load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs +- open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs diff --git a/document-properties/open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs b/document-properties/open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs new file mode 100644 index 0000000000..8fdd5bc273 --- /dev/null +++ b/document-properties/open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs @@ -0,0 +1,18 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Create a new workbook (or load an existing one) + Workbook workbook = new Workbook(); + + // Add a custom Boolean property named "IsReviewed" with value true + workbook.CustomDocumentProperties.Add("IsReviewed", true); + + // Save the workbook to a file + workbook.Save("output.xlsx", SaveFormat.Xlsx); + } +} \ No newline at end of file diff --git a/index.json b/index.json index d17ec630f9..61cc2a5e92 100644 --- a/index.json +++ b/index.json @@ -184,6 +184,11 @@ "file": "open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs", "title": "Open a spreadsheet and set the Language built\u2011in property to \"fr-FR\" for localization." }, + { + "category": "document-properties", + "file": "open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs", + "title": "Open a workbook and add a custom Boolean property \"IsReviewed\" set to true." + }, { "category": "document-properties", "file": "open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs", From 8ce0a162ad6febecdc90313744702e753c4164ad Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:55:08 +0500 Subject: [PATCH 16/47] Add example: load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value --- document-properties/agents.md | 1 + ...-projectid-and-update-its-integer-value.cs | 32 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 38 insertions(+) create mode 100644 document-properties/load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 4aff8b3e8b..844f46a95d 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -69,3 +69,4 @@ Output files are written to the working directory. - open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs - load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs - open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs +- load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs diff --git a/document-properties/load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs b/document-properties/load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs new file mode 100644 index 0000000000..67602743c6 --- /dev/null +++ b/document-properties/load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs @@ -0,0 +1,32 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class UpdateProjectIdProperty +{ + static void Main() + { + // Load the workbook from a file + Workbook workbook = new Workbook("input.xlsx"); + + // Get the collection of custom document properties + CustomDocumentPropertyCollection customProps = workbook.CustomDocumentProperties; + + // Try to retrieve the "ProjectId" property + DocumentProperty projectIdProp = customProps["ProjectId"]; + + if (projectIdProp != null) + { + // Property exists – update its integer value + projectIdProp.Value = 12345; // new integer value + } + else + { + // Property does not exist – add it with the desired integer value + customProps.Add("ProjectId", 12345); + } + + // Save the modified workbook + workbook.Save("output.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 61cc2a5e92..fbd19ed4a5 100644 --- a/index.json +++ b/index.json @@ -164,6 +164,11 @@ "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", "title": "Load a workbook and retrieve the Title built\u2011in property for verification." }, + { + "category": "document-properties", + "file": "load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs", + "title": "Load a workbook, locate the custom property \"ProjectId\", and update its integer value." + }, { "category": "document-properties", "file": "load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs", From 164518f492387c594ce546d0ff7379f46e4ff228 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:56:16 +0500 Subject: [PATCH 17/47] Add example: open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata --- document-properties/agents.md | 1 + ...y-isreviewed-to-clean-obsolete-metadata.cs | 51 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 57 insertions(+) create mode 100644 document-properties/open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 844f46a95d..dd5a35557c 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -70,3 +70,4 @@ Output files are written to the working directory. - load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs - open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs - load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs +- open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs diff --git a/document-properties/open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs b/document-properties/open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs new file mode 100644 index 0000000000..b6f1fd4a60 --- /dev/null +++ b/document-properties/open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; +using Aspose.Cells; + +namespace AsposeCellsExamples +{ + public class RemoveCustomPropertyDemo + { + public static void Main() + { + Run(); + } + + public static void Run() + { + string inputPath = "input.xlsx"; + string outputPath = "output.xlsx"; + + try + { + // Verify input file exists + if (!File.Exists(inputPath)) + { + Console.WriteLine($"Input file not found: {inputPath}"); + return; + } + + // Load workbook from file stream + using (FileStream stream = new FileStream(inputPath, FileMode.Open, FileAccess.Read)) + { + Workbook workbook = new Workbook(stream); + + // Remove custom property if it exists + if (workbook.CustomDocumentProperties.Contains("IsReviewed")) + { + workbook.CustomDocumentProperties.Remove("IsReviewed"); + } + + // Save the modified workbook + workbook.Save(outputPath, SaveFormat.Xlsx); + } + + Console.WriteLine($"Custom property \"IsReviewed\" removed and file saved to {outputPath}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index fbd19ed4a5..c0a3a05ddd 100644 --- a/index.json +++ b/index.json @@ -184,6 +184,11 @@ "file": "open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs", "title": "Open a file and update the Author built\u2011in property with the correct contributor identifier." }, + { + "category": "document-properties", + "file": "open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs", + "title": "Open a spreadsheet and remove the custom property \"IsReviewed\" to clean obsolete metadata." + }, { "category": "document-properties", "file": "open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs", From fce4da8beb7ab43a9f9887b0aede490a320e963a Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:56:53 +0500 Subject: [PATCH 18/47] Add example: load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding --- document-properties/agents.md | 1 + ...roperty-clientname-exists-before-adding.cs | 30 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 36 insertions(+) create mode 100644 document-properties/load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index dd5a35557c..991c2b3acf 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -71,3 +71,4 @@ Output files are written to the working directory. - open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs - load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs - open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs +- load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs diff --git a/document-properties/load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs b/document-properties/load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs new file mode 100644 index 0000000000..72dd3478aa --- /dev/null +++ b/document-properties/load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs @@ -0,0 +1,30 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Load an existing workbook + Workbook workbook = new Workbook("input.xlsx"); + + // Access the custom document properties collection + CustomDocumentPropertyCollection customProps = workbook.CustomDocumentProperties; + + // Check if the property "ClientName" already exists + if (!customProps.Contains("ClientName")) + { + // Property does not exist, add it with a sample value + customProps.Add("ClientName", "Acme Corp"); + Console.WriteLine("Custom property 'ClientName' added."); + } + else + { + Console.WriteLine("Custom property 'ClientName' already exists."); + } + + // Save the workbook with the (potentially) new property + workbook.Save("output.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index c0a3a05ddd..81b6cad273 100644 --- a/index.json +++ b/index.json @@ -154,6 +154,11 @@ "file": "load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs", "title": "Load a workbook and assign the DocumentVersion built\u2011in property the value \"2.0\"." }, + { + "category": "document-properties", + "file": "load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs", + "title": "Load a workbook and check whether a custom property \"ClientName\" exists before adding." + }, { "category": "document-properties", "file": "load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs", From 4d370b44ebb2a389eca5defc065947f0faa5d662 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:57:33 +0500 Subject: [PATCH 19/47] Add example: open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value --- document-properties/agents.md | 1 + ...-properties-logging-each-name-and-value.cs | 27 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 33 insertions(+) create mode 100644 document-properties/open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 991c2b3acf..c296b88835 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -72,3 +72,4 @@ Output files are written to the working directory. - load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs - open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs - load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs +- open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs diff --git a/document-properties/open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs b/document-properties/open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs new file mode 100644 index 0000000000..0844af39cc --- /dev/null +++ b/document-properties/open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs @@ -0,0 +1,27 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsExamples +{ + class Program + { + static void Main(string[] args) + { + // Path to the Excel file to be opened + string filePath = "input.xlsx"; + + // Load the workbook from the specified file + Workbook workbook = new Workbook(filePath); + + // Access the collection of built‑in document properties + BuiltInDocumentPropertyCollection builtInProps = workbook.BuiltInDocumentProperties; + + // Iterate through each property and log its name and value + foreach (DocumentProperty prop in builtInProps) + { + Console.WriteLine($"{prop.Name}: {prop.Value}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 81b6cad273..9e74d683f1 100644 --- a/index.json +++ b/index.json @@ -184,6 +184,11 @@ "file": "load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs", "title": "Load an Excel file and create a custom property \"ProjectId\" with an integer identifier." }, + { + "category": "document-properties", + "file": "open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs", + "title": "Open a file and iterate through all built\u2011in properties, logging each name and value." + }, { "category": "document-properties", "file": "open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs", From 027aeb73a9dab8e9b277271ad6f5cad4753eb7ef Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:58:17 +0500 Subject: [PATCH 20/47] Add example: load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json --- document-properties/agents.md | 1 + ...ng-their-names-types-and-values-to-json.cs | 42 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 48 insertions(+) create mode 100644 document-properties/load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index c296b88835..bc50485c8a 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -73,3 +73,4 @@ Output files are written to the working directory. - open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs - load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs - open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs +- load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs diff --git a/document-properties/load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs b/document-properties/load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs new file mode 100644 index 0000000000..fc5f8a1d42 --- /dev/null +++ b/document-properties/load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class ExportCustomPropertiesToJson +{ + static void Main() + { + // Path to the Excel workbook to be processed + string workbookPath = "input.xlsx"; + + // Load the workbook from the specified file + Workbook workbook = new Workbook(workbookPath); + + // Prepare a list to hold property information + var properties = new List(); + + // Enumerate all custom document properties + foreach (DocumentProperty prop in workbook.CustomDocumentProperties) + { + // Capture name, type (as string), and value of each property + properties.Add(new + { + Name = prop.Name, + Type = prop.Type.ToString(), + Value = prop.Value + }); + } + + // Serialize the list to JSON with indentation for readability + string json = JsonSerializer.Serialize(properties, new JsonSerializerOptions { WriteIndented = true }); + + // Write the JSON output to a file + string outputPath = "customProperties.json"; + File.WriteAllText(outputPath, json); + + Console.WriteLine($"Custom properties exported to {outputPath}"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 9e74d683f1..7e17738fe5 100644 --- a/index.json +++ b/index.json @@ -164,6 +164,11 @@ "file": "load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs", "title": "Load a workbook and disable the LinksUpToDate built\u2011in property to prevent link checks." }, + { + "category": "document-properties", + "file": "load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs", + "title": "Load a workbook and enumerate custom properties, exporting their names, types, and values to JSON." + }, { "category": "document-properties", "file": "load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs", From cf41f1849a2c30694aa978bf3c4ee5554fb83fd2 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 19:59:03 +0500 Subject: [PATCH 21/47] Add example: open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them --- document-properties/agents.md | 1 + ...perties-by-datetime-type-then-list-them.cs | 30 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 36 insertions(+) create mode 100644 document-properties/open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index bc50485c8a..67f71f5628 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -74,3 +74,4 @@ Output files are written to the working directory. - load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs - open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs - load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs +- open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs diff --git a/document-properties/open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs b/document-properties/open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs new file mode 100644 index 0000000000..717b9874bb --- /dev/null +++ b/document-properties/open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs @@ -0,0 +1,30 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Load an existing workbook (replace with your file path) + Workbook workbook = new Workbook("input.xlsx"); + + // Access the custom document properties collection + CustomDocumentPropertyCollection customProps = workbook.CustomDocumentProperties; + + Console.WriteLine("DateTime custom properties:"); + + // Iterate through all custom properties and output those of DateTime type + foreach (DocumentProperty prop in customProps) + { + if (prop.Type == PropertyType.DateTime) + { + // Display property name and its DateTime value in ISO 8601 format + Console.WriteLine($"{prop.Name}: {prop.ToDateTime():O}"); + } + } + + // Save the workbook (optional, as no changes are made to the file) + workbook.Save("output.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 7e17738fe5..30b13c30cc 100644 --- a/index.json +++ b/index.json @@ -199,6 +199,11 @@ "file": "open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs", "title": "Open a file and update the Author built\u2011in property with the correct contributor identifier." }, + { + "category": "document-properties", + "file": "open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs", + "title": "Open a spreadsheet and filter custom properties by DateTime type, then list them." + }, { "category": "document-properties", "file": "open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs", From e46baa8b2fc5d69b385c859893a837dbb561f1f3 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:00:24 +0500 Subject: [PATCH 22/47] Add example: instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically --- document-properties/agents.md | 1 + ...-source-to-destination-programmatically.cs | 58 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 64 insertions(+) create mode 100644 document-properties/instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 67f71f5628..dd53e216d3 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -75,3 +75,4 @@ Output files are written to the working directory. - open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs - load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs - open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs +- instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs diff --git a/document-properties/instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs b/document-properties/instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs new file mode 100644 index 0000000000..20947a0889 --- /dev/null +++ b/document-properties/instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs @@ -0,0 +1,58 @@ +using System; +using System.IO; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsDocumentPropertiesCopy +{ + class Program + { + static void Main() + { + try + { + // Create source workbook and set some built‑in and custom properties + Workbook sourceWorkbook = new Workbook(); + sourceWorkbook.BuiltInDocumentProperties["Author"].Value = "John Smith"; + sourceWorkbook.BuiltInDocumentProperties["Title"].Value = "Sample Source Workbook"; + sourceWorkbook.CustomDocumentProperties.Add("ReviewedBy", "Jane Doe"); + sourceWorkbook.CustomDocumentProperties.Add("Revision", 3); + + // Create destination workbook (empty) + Workbook destinationWorkbook = new Workbook(); + + // ----- Copy Built‑in Document Properties ----- + foreach (DocumentProperty srcProp in sourceWorkbook.BuiltInDocumentProperties) + { + // Ensure the destination has the same property and assign its value + destinationWorkbook.BuiltInDocumentProperties[srcProp.Name].Value = srcProp.Value; + } + + // ----- Copy Custom Document Properties ----- + foreach (DocumentProperty srcProp in sourceWorkbook.CustomDocumentProperties) + { + // If the property already exists, update its value; otherwise add it + if (destinationWorkbook.CustomDocumentProperties.Contains(srcProp.Name)) + { + destinationWorkbook.CustomDocumentProperties[srcProp.Name].Value = srcProp.Value; + } + else + { + // Convert the value to string to match the overload that accepts (string, string) + destinationWorkbook.CustomDocumentProperties.Add(srcProp.Name, srcProp.Value?.ToString() ?? string.Empty); + } + } + + // Save both workbooks to verify the copy + sourceWorkbook.Save("SourceWorkbook.xlsx"); + destinationWorkbook.Save("DestinationWorkbook.xlsx"); + + Console.WriteLine("Document properties copied successfully."); + } + catch (Exception ex) + { + Console.WriteLine($"Error: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 30b13c30cc..5790f81ad8 100644 --- a/index.json +++ b/index.json @@ -144,6 +144,11 @@ "file": "instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs", "title": "Instantiate a workbook and obtain the DocumentVersion built\u2011in property to check version information." }, + { + "category": "document-properties", + "file": "instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs", + "title": "Instantiate two workbooks and copy all document properties from source to destination programmatically." + }, { "category": "document-properties", "file": "load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs", From c0d8580e7429e0e2e076d72ee35e223ac684ad46 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:01:11 +0500 Subject: [PATCH 23/47] Add example: load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook --- document-properties/agents.md | 1 + ...roperties-into-a-newly-created-workbook.cs | 28 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 34 insertions(+) create mode 100644 document-properties/load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index dd53e216d3..7fab7728b3 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -76,3 +76,4 @@ Output files are written to the working directory. - load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs - open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs - instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs +- load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs diff --git a/document-properties/load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs b/document-properties/load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs new file mode 100644 index 0000000000..e618ff77b3 --- /dev/null +++ b/document-properties/load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs @@ -0,0 +1,28 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsCloneBuiltInProperties +{ + class Program + { + static void Main() + { + // Load the template workbook (source) + Workbook sourceWorkbook = new Workbook("TemplateWorkbook.xlsx"); + + // Create a new empty workbook (destination) + Workbook destWorkbook = new Workbook(); + + // Clone built‑in document properties from source to destination + foreach (DocumentProperty sourceProp in sourceWorkbook.BuiltInDocumentProperties) + { + // Ensure the destination has the same property and assign its value + destWorkbook.BuiltInDocumentProperties[sourceProp.Name].Value = sourceProp.Value; + } + + // Save the destination workbook with the cloned properties + destWorkbook.Save("ClonedPropertiesWorkbook.xlsx"); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 5790f81ad8..c7c0767afe 100644 --- a/index.json +++ b/index.json @@ -154,6 +154,11 @@ "file": "load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs", "title": "Load a spreadsheet and read the Language built\u2011in property to determine locale settings." }, + { + "category": "document-properties", + "file": "load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs", + "title": "Load a template workbook and clone its built\u2011in properties into a newly created workbook." + }, { "category": "document-properties", "file": "load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs", From d9623a8be213112b83240e13f65d62a267b0f30a Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:01:59 +0500 Subject: [PATCH 24/47] Add example: open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving --- document-properties/agents.md | 1 + ...-semantic-version-pattern-before-saving.cs | 31 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 37 insertions(+) create mode 100644 document-properties/open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 7fab7728b3..8743365b2b 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -77,3 +77,4 @@ Output files are written to the working directory. - open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs - instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs - load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs +- open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs diff --git a/document-properties/open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs b/document-properties/open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs new file mode 100644 index 0000000000..917a0e7ad4 --- /dev/null +++ b/document-properties/open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs @@ -0,0 +1,31 @@ +using System; +using System.Text.RegularExpressions; +using Aspose.Cells; + +class DocumentVersionValidator +{ + static void Main() + { + // Load an existing workbook + string inputPath = "input.xlsx"; + Workbook workbook = new Workbook(inputPath); + + // Retrieve the DocumentVersion property + string version = workbook.BuiltInDocumentProperties.DocumentVersion; + + // Semantic version pattern: major.minor.patch with optional prerelease and build metadata + string semVerPattern = @"^\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+)?$"; + + // Validate the version string + if (!Regex.IsMatch(version ?? string.Empty, semVerPattern)) + { + Console.WriteLine($"Invalid DocumentVersion '{version}'. Setting default version."); + workbook.BuiltInDocumentProperties.DocumentVersion = "1.0.0"; + } + + // Save the workbook + string outputPath = "output.xlsx"; + workbook.Save(outputPath, SaveFormat.Xlsx); + Console.WriteLine($"Workbook saved to {outputPath}"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index c7c0767afe..60ec60ced8 100644 --- a/index.json +++ b/index.json @@ -239,6 +239,11 @@ "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", "title": "Open a workbook and query the ScaleCrop built\u2011in property to view image scaling flag." }, + { + "category": "document-properties", + "file": "open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs", + "title": "Open a workbook and validate that DocumentVersion matches a semantic version pattern before saving." + }, { "category": "document-properties", "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", From aa329a8469c5f72873fee4cd8ba3c00fbf95096a Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:12:03 +0500 Subject: [PATCH 25/47] Add example: load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code --- document-properties/agents.md | 1 + ...guage-contains-a-valid-net-culture-code.cs | 66 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 72 insertions(+) create mode 100644 document-properties/load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 8743365b2b..0cbabb1a6a 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -78,3 +78,4 @@ Output files are written to the working directory. - instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs - load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs - open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs +- load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs diff --git a/document-properties/load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs b/document-properties/load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs new file mode 100644 index 0000000000..fb53272961 --- /dev/null +++ b/document-properties/load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs @@ -0,0 +1,66 @@ +using System; +using System.Globalization; +using System.IO; +using Aspose.Cells; + +namespace AsposeCellsExamples +{ + public class VerifyWorkbookLanguage + { + public static void Run(string filePath) + { + // Prevent FileNotFoundException + if (!File.Exists(filePath)) + { + Console.WriteLine($"File not found: {filePath}"); + return; + } + + try + { + // Load the workbook with default load options + LoadOptions loadOptions = new LoadOptions(); + Workbook workbook = new Workbook(filePath, loadOptions); + + // Retrieve the language property from built‑in document properties + string language = workbook.BuiltInDocumentProperties.Language; + + // Report if the property is missing + if (string.IsNullOrWhiteSpace(language)) + { + Console.WriteLine("The workbook does not contain a language property."); + return; + } + + // Validate the language code + try + { + CultureInfo culture = new CultureInfo(language); + Console.WriteLine($"Valid language code found: {language} ({culture.DisplayName})"); + } + catch (CultureNotFoundException) + { + Console.WriteLine($"Invalid language code: {language}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"Error processing workbook: {ex.Message}"); + } + } + + // Entry point for the console application + public static void Main(string[] args) + { + string filePath = args.Length > 0 ? args[0] : string.Empty; + + if (string.IsNullOrWhiteSpace(filePath)) + { + Console.Write("Enter the path to the Excel file: "); + filePath = Console.ReadLine(); + } + + Run(filePath); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 60ec60ced8..8a647085bd 100644 --- a/index.json +++ b/index.json @@ -199,6 +199,11 @@ "file": "load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs", "title": "Load an Excel file and create a custom property \"ProjectId\" with an integer identifier." }, + { + "category": "document-properties", + "file": "load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs", + "title": "Load an Excel file and verify that Language contains a valid .NET culture code." + }, { "category": "document-properties", "file": "open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs", From cda996c56667b7d30e08dfd24807e4b7532cb192 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:12:47 +0500 Subject: [PATCH 26/47] Add example: open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf --- document-properties/agents.md | 1 + ...re-the-flag-persists-when-saving-as-pdf.cs | 31 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 37 insertions(+) create mode 100644 document-properties/open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 0cbabb1a6a..32e993c80f 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -79,3 +79,4 @@ Output files are written to the working directory. - load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs - open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs - load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs +- open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs diff --git a/document-properties/open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs b/document-properties/open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs new file mode 100644 index 0000000000..8305ab6a99 --- /dev/null +++ b/document-properties/open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs @@ -0,0 +1,31 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; +using Aspose.Cells.Rendering; + +namespace AsposeCellsScaleCropPdfDemo +{ + class Program + { + static void Main() + { + // Create a new workbook (or load an existing one) + Workbook workbook = new Workbook(); + + // Access the built‑in document properties collection + BuiltInDocumentPropertyCollection properties = workbook.BuiltInDocumentProperties; + + // Set the ScaleCrop flag to true – this controls the display mode of the document thumbnail + properties.ScaleCrop = true; + + // Optional: verify that the property is set + Console.WriteLine("ScaleCrop property value: " + properties.ScaleCrop); + + // Save the workbook as a PDF. + // The ScaleCrop flag is stored in the document properties and will be persisted in the PDF output. + workbook.Save("output.pdf", SaveFormat.Pdf); + + Console.WriteLine("Workbook saved as PDF with ScaleCrop enabled."); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 8a647085bd..5f0f85c1a5 100644 --- a/index.json +++ b/index.json @@ -249,6 +249,11 @@ "file": "open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs", "title": "Open a workbook and validate that DocumentVersion matches a semantic version pattern before saving." }, + { + "category": "document-properties", + "file": "open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs", + "title": "Open a workbook, set ScaleCrop to true, and ensure the flag persists when saving as PDF." + }, { "category": "document-properties", "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", From 1bf7780f7620eece7fde7c797c88093c03bdc9de Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:13:29 +0500 Subject: [PATCH 27/47] Add example: instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling --- document-properties/agents.md | 1 + ...perty-to-demonstrate-exception-handling.cs | 32 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 38 insertions(+) create mode 100644 document-properties/instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 32e993c80f..bbc987a70f 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -80,3 +80,4 @@ Output files are written to the working directory. - open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs - load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs - open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs +- instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs diff --git a/document-properties/instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs b/document-properties/instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs new file mode 100644 index 0000000000..fcb2bc0827 --- /dev/null +++ b/document-properties/instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs @@ -0,0 +1,32 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; // Required for DocumentProperty + +class Program +{ + static void Main() + { + // Instantiate a new workbook (creation rule) + Workbook workbook = new Workbook(); + + try + { + // Attempt to retrieve a built‑in property that does not exist. + // The indexer returns null when the name is not a recognized built‑in property. + DocumentProperty prop = workbook.BuiltInDocumentProperties["NonExistentProperty"]; + + // Accessing .Value on a null reference will throw a NullReferenceException. + // This demonstrates exception handling for an invalid property access. + prop.Value = "Some value"; + } + catch (Exception ex) + { + // Catch and display the exception details. + Console.WriteLine($"Exception caught: {ex.GetType().Name}"); + Console.WriteLine($"Message: {ex.Message}"); + } + + // Save the workbook to disk (save rule) + workbook.Save("DemoWorkbook.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 5f0f85c1a5..42529015a2 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", "title": "Create a workbook and set the Title built\u2011in property to a descriptive project name." }, + { + "category": "document-properties", + "file": "instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs", + "title": "Instantiate a workbook and deliberately access a non\u2011existent built\u2011in property to demonstrate exception handling." + }, { "category": "document-properties", "file": "instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs", From 88b878f7e312382187736bf2c5cb170cd56423a0 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:14:14 +0500 Subject: [PATCH 28/47] Add example: load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer --- document-properties/agents.md | 1 + ...-safely-read-a-custom-property-reviewer.cs | 42 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 48 insertions(+) create mode 100644 document-properties/load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index bbc987a70f..faea20e49d 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -81,3 +81,4 @@ Output files are written to the working directory. - load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs - open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs - instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs +- load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs diff --git a/document-properties/load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs b/document-properties/load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs new file mode 100644 index 0000000000..1fcd4ee316 --- /dev/null +++ b/document-properties/load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs @@ -0,0 +1,42 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Path to the Excel file to be loaded + string filePath = "input.xlsx"; + + // Load the workbook (using the load rule) + Workbook workbook = new Workbook(filePath); + + try + { + // Try to retrieve the custom document property named "Reviewer" + DocumentProperty reviewerProp = workbook.CustomDocumentProperties["Reviewer"]; + + if (reviewerProp != null) + { + // Property exists – output its value + Console.WriteLine($"Reviewer: {reviewerProp.Value}"); + } + else + { + // Property not found – inform the user + Console.WriteLine("Custom property 'Reviewer' not found."); + } + } + catch (CellsException ex) + { + // Handle Aspose.Cells specific exceptions + Console.WriteLine($"Aspose.Cells error: {ex.Message} (Code: {ex.Code})"); + } + catch (Exception ex) + { + // Handle any other unexpected exceptions + Console.WriteLine($"Unexpected error: {ex.Message}"); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 42529015a2..c51704b580 100644 --- a/index.json +++ b/index.json @@ -159,6 +159,11 @@ "file": "load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs", "title": "Load a spreadsheet and read the Language built\u2011in property to determine locale settings." }, + { + "category": "document-properties", + "file": "load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs", + "title": "Load a spreadsheet and use try\u2011catch to safely read a custom property \"Reviewer\"." + }, { "category": "document-properties", "file": "load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs", From 58c6be9e4707603108453459813c01a886f1bcb4 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:14:57 +0500 Subject: [PATCH 29/47] Add example: open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties --- document-properties/agents.md | 1 + ...-fields-appear-in-saved-file-properties.cs | 63 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 69 insertions(+) create mode 100644 document-properties/open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index faea20e49d..8f9c893381 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -82,3 +82,4 @@ Output files are written to the working directory. - open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs - instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs - load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs +- open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs diff --git a/document-properties/open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs b/document-properties/open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs new file mode 100644 index 0000000000..a2e8e8fe08 --- /dev/null +++ b/document-properties/open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs @@ -0,0 +1,63 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Metadata; +using Aspose.Cells.Properties; + +namespace AsposeCellsMetadataDemo +{ + class Program + { + static void Main() + { + // ----------------------------------------------------------------- + // Step 1: Create a new workbook and set initial properties + // ----------------------------------------------------------------- + string initialFile = "InitialWorkbook.xlsx"; + Workbook wb = new Workbook(); // create a new workbook + // Set some built‑in properties directly on the workbook + wb.BuiltInDocumentProperties.Author = "Original Author"; + wb.BuiltInDocumentProperties.Title = "Original Title"; + // Add a custom property + wb.CustomDocumentProperties.Add("InitialCustom", "Value1"); + // Save the workbook to disk + wb.Save(initialFile); + + // ----------------------------------------------------------------- + // Step 2: Load workbook metadata with DocumentProperties option + // ----------------------------------------------------------------- + MetadataOptions options = new MetadataOptions(MetadataType.DocumentProperties); + WorkbookMetadata metadata = new WorkbookMetadata(initialFile, options); // load metadata + + // ----------------------------------------------------------------- + // Step 3: Modify built‑in and custom properties via metadata API + // ----------------------------------------------------------------- + // Built‑in properties are read‑write + metadata.BuiltInDocumentProperties.Author = "Aspose Developer"; + metadata.BuiltInDocumentProperties.Title = "Metadata Updated Title"; + + // Add or update custom properties + metadata.CustomDocumentProperties.Add("UpdatedCustom", "NewValue"); + // (If the property already exists, you could also modify its Value) + + // ----------------------------------------------------------------- + // Step 4: Save the modified metadata back to the file + // ----------------------------------------------------------------- + metadata.Save(initialFile); // overwrite the same file with updated metadata + + // ----------------------------------------------------------------- + // Step 5: Reload the workbook and verify that properties were saved + // ----------------------------------------------------------------- + Workbook verifiedWb = new Workbook(initialFile); + + // Verify built‑in properties + Console.WriteLine("Verified Author: " + verifiedWb.BuiltInDocumentProperties.Author); + Console.WriteLine("Verified Title: " + verifiedWb.BuiltInDocumentProperties.Title); + + // Verify custom properties + Console.WriteLine("Verified Custom Property 'InitialCustom': " + + verifiedWb.CustomDocumentProperties["InitialCustom"].Value); + Console.WriteLine("Verified Custom Property 'UpdatedCustom': " + + verifiedWb.CustomDocumentProperties["UpdatedCustom"].Value); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index c51704b580..fc8c990b73 100644 --- a/index.json +++ b/index.json @@ -249,6 +249,11 @@ "file": "open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs", "title": "Open a workbook and add a custom property \"ProcessedDate\" with the current DateTime value." }, + { + "category": "document-properties", + "file": "open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs", + "title": "Open a workbook and confirm that application metadata fields appear in saved file properties." + }, { "category": "document-properties", "file": "open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs", From 958d600f7454f11ce74b8f16e9dd22de1867518b Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:15:39 +0500 Subject: [PATCH 30/47] Add example: load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes --- document-properties/agents.md | 1 + ...-file-to-xlsx-format-preserving-changes.cs | 37 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 43 insertions(+) create mode 100644 document-properties/load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 8f9c893381..ea9c11010e 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -83,3 +83,4 @@ Output files are written to the working directory. - instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs - load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs - open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs +- load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs diff --git a/document-properties/load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs b/document-properties/load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs new file mode 100644 index 0000000000..0e2579e54e --- /dev/null +++ b/document-properties/load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs @@ -0,0 +1,37 @@ +using System; +using Aspose.Cells; + +namespace AsposeCellsDemo +{ + class Program + { + static void Main() + { + // Load an existing workbook from disk + string inputPath = "input.xlsx"; + Workbook workbook = new Workbook(inputPath); + + // Modify built‑in document properties + workbook.BuiltInDocumentProperties["Author"].Value = "Jane Doe"; + workbook.BuiltInDocumentProperties["Title"].Value = "Modified Workbook"; + + // Add a custom document property + workbook.CustomDocumentProperties.Add("Reviewed", true); + + // Change the default style (font name and size) + workbook.DefaultStyle.Font.Name = "Calibri"; + workbook.DefaultStyle.Font.Size = 11; + + // Add a new worksheet and insert some data + int newSheetIndex = workbook.Worksheets.Add(); + Worksheet newSheet = workbook.Worksheets[newSheetIndex]; + newSheet.Name = "Summary"; + newSheet.Cells["A1"].PutValue("Report generated on:"); + newSheet.Cells["B1"].PutValue(DateTime.Now); + + // Save the modified workbook as XLSX, preserving all changes + string outputPath = "output.xlsx"; + workbook.Save(outputPath, SaveFormat.Xlsx); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index fc8c990b73..3c17fedf4e 100644 --- a/index.json +++ b/index.json @@ -199,6 +199,11 @@ "file": "load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs", "title": "Load a workbook, locate the custom property \"ProjectId\", and update its integer value." }, + { + "category": "document-properties", + "file": "load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs", + "title": "Load a workbook, modify several properties, and save the file to XLSX format preserving changes." + }, { "category": "document-properties", "file": "load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs", From dbe5fbf595c76fd3d9cdde79ab885da049e00266 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:16:15 +0500 Subject: [PATCH 31/47] Add example: open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing --- document-properties/agents.md | 1 + ...to-csv-format-for-downstream-processing.cs | 37 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 43 insertions(+) create mode 100644 document-properties/open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index ea9c11010e..34eacbde3f 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -84,3 +84,4 @@ Output files are written to the working directory. - load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs - open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs - load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs +- open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs diff --git a/document-properties/open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs b/document-properties/open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs new file mode 100644 index 0000000000..4dac9d7c54 --- /dev/null +++ b/document-properties/open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs @@ -0,0 +1,37 @@ +using System; +using Aspose.Cells; + +namespace AsposeCellsDocumentPropertiesToCsv +{ + class Program + { + static void Main() + { + // Path to the source Excel file + string sourcePath = "input.xlsx"; + + // Path for the resulting CSV file + string csvPath = "output.csv"; + + // Load the workbook from the existing file (load rule) + Workbook workbook = new Workbook(sourcePath); + + // Update built‑in document properties (property rule) + // Example: set Author and Title + workbook.BuiltInDocumentProperties["Author"].Value = "John Doe"; + workbook.BuiltInDocumentProperties["Title"].Value = "Sample Data Export"; + + // Add a custom document property (property rule) + // Example: add a custom property named "ExportedOn" + workbook.CustomDocumentProperties.Add("ExportedOn", DateTime.Now); + + // Save the workbook as CSV (save rule) + workbook.Save(csvPath, SaveFormat.Csv); + + // Clean up + workbook.Dispose(); + + Console.WriteLine($"Workbook properties updated and saved as CSV to '{csvPath}'."); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 3c17fedf4e..150c561128 100644 --- a/index.json +++ b/index.json @@ -274,6 +274,11 @@ "file": "open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs", "title": "Open a workbook, set ScaleCrop to true, and ensure the flag persists when saving as PDF." }, + { + "category": "document-properties", + "file": "open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs", + "title": "Open a workbook, update document properties, and export the result to CSV format for downstream processing." + }, { "category": "document-properties", "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", From 514562e80dff7a1eddb391f0072ac529d862b447 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:16:54 +0500 Subject: [PATCH 32/47] Add example: instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata --- document-properties/agents.md | 1 + ...e-the-document-as-pdf-to-embed-metadata.cs | 30 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 36 insertions(+) create mode 100644 document-properties/instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 34eacbde3f..f12100dd15 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -85,3 +85,4 @@ Output files are written to the working directory. - open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs - load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs - open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs +- instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs diff --git a/document-properties/instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs b/document-properties/instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs new file mode 100644 index 0000000000..2dedfe751b --- /dev/null +++ b/document-properties/instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs @@ -0,0 +1,30 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Rendering; + +class Program +{ + static void Main() + { + // Instantiate a new workbook + Workbook workbook = new Workbook(); + + // Adjust built‑in document properties + workbook.BuiltInDocumentProperties.Author = "John Doe"; + workbook.BuiltInDocumentProperties.Title = "Sample PDF with Metadata"; + workbook.BuiltInDocumentProperties.Subject = "Aspose.Cells Metadata Demo"; + workbook.BuiltInDocumentProperties.Company = "Acme Corp"; + + // (Optional) Add a custom document property that will be embedded into the PDF + workbook.CustomDocumentProperties.Add("Project", "MetadataDemo"); + + // Configure PDF save options to export custom properties into the PDF file + PdfSaveOptions pdfOptions = new PdfSaveOptions + { + CustomPropertiesExport = PdfCustomPropertiesExport.Standard + }; + + // Save the workbook as PDF with the specified options + workbook.Save("Output.pdf", pdfOptions); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 150c561128..aba2475dbb 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", "title": "Create a workbook and set the Title built\u2011in property to a descriptive project name." }, + { + "category": "document-properties", + "file": "instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs", + "title": "Instantiate a workbook, adjust built\u2011in properties, and save the document as PDF to embed metadata." + }, { "category": "document-properties", "file": "instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs", From f6af5763e0f3431af3b86bf478d492f661a4116a Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:18:08 +0500 Subject: [PATCH 33/47] Add example: batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb --- document-properties/agents.md | 1 + ...g-each-files-language-property-to-en-gb.cs | 63 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 69 insertions(+) create mode 100644 document-properties/batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index f12100dd15..487dac0b6e 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -86,3 +86,4 @@ Output files are written to the working directory. - load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs - open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs - instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs +- batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs diff --git a/document-properties/batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs b/document-properties/batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs new file mode 100644 index 0000000000..5b2889c6a8 --- /dev/null +++ b/document-properties/batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs @@ -0,0 +1,63 @@ +using System; +using System.IO; +using Aspose.Cells; + +namespace BatchSetLanguageApp +{ + class BatchSetLanguage + { + static void Main() + { + try + { + // Folder containing the workbooks to process + string folderPath = @"C:\Path\To\Folder"; + + // Verify folder exists + if (!Directory.Exists(folderPath)) + { + Console.WriteLine($"Folder not found: {folderPath}"); + return; + } + + // Retrieve all files in the folder + string[] allFiles = Directory.GetFiles(folderPath, "*.*", SearchOption.TopDirectoryOnly); + + foreach (string filePath in allFiles) + { + try + { + // Process only supported Excel formats + string ext = Path.GetExtension(filePath).ToLowerInvariant(); + if (ext != ".xls" && ext != ".xlsx" && ext != ".xlsm" && ext != ".xlsb" && ext != ".csv") + continue; + + // Ensure the file exists before loading + if (!File.Exists(filePath)) + { + Console.WriteLine($"File not found: {filePath}"); + continue; + } + + // Load the workbook (lifecycle rule: load) + Workbook workbook = new Workbook(filePath); + + // Set the built‑in document property "Language" to "en-GB" + workbook.BuiltInDocumentProperties.Language = "en-GB"; + + // Save the workbook back to the same file (lifecycle rule: save) + workbook.Save(filePath); + } + catch (Exception ex) + { + Console.WriteLine($"Error processing '{filePath}': {ex.Message}"); + } + } + } + catch (Exception ex) + { + Console.WriteLine($"Unexpected error: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index aba2475dbb..91cdb7fff4 100644 --- a/index.json +++ b/index.json @@ -129,6 +129,11 @@ "file": "update-the-text-direction-of-all-comments-in-a-worksheet-to-lefttoright-for-standard-layout.cs", "title": "Update the text direction of all comments in a worksheet to LeftToRight for standard layout." }, + { + "category": "document-properties", + "file": "batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs", + "title": "Batch process all workbooks in a folder, setting each file's Language property to \"en-GB\"." + }, { "category": "document-properties", "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", From 32626a3cc9802f94c40f1ac02bc0b818d47b76a8 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:18:46 +0500 Subject: [PATCH 34/47] Add example: iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30 --- document-properties/agents.md | 1 + ...te-every-documentversion-property-to-30.cs | 44 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 50 insertions(+) create mode 100644 document-properties/iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 487dac0b6e..4c29bcb60b 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -87,3 +87,4 @@ Output files are written to the working directory. - open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs - instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs - batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs +- iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs diff --git a/document-properties/iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs b/document-properties/iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs new file mode 100644 index 0000000000..e1cda23fb6 --- /dev/null +++ b/document-properties/iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using Aspose.Cells; + +namespace UpdateDocumentVersion +{ + class Program + { + static void Main(string[] args) + { + // Path to the folder containing Excel files + string folderPath = @"C:\ExcelFiles"; + + // Get all Excel files in the folder (including .xls, .xlsx, .xlsm, .ods, etc.) + string[] excelFiles = Directory.GetFiles(folderPath, "*.*", SearchOption.TopDirectoryOnly); + + foreach (string filePath in excelFiles) + { + // Filter only supported Excel extensions + string extension = Path.GetExtension(filePath).ToLowerInvariant(); + if (extension != ".xls" && extension != ".xlsx" && extension != ".xlsm" && extension != ".xlsb" && extension != ".ods") + continue; + + try + { + // Load the workbook from the file + Workbook workbook = new Workbook(filePath); + + // Update the built‑in DocumentVersion property + workbook.BuiltInDocumentProperties.DocumentVersion = "3.0"; + + // Save the workbook back to the same file (overwrites original) + workbook.Save(filePath); + + Console.WriteLine($"Updated DocumentVersion for: {Path.GetFileName(filePath)}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error processing file '{filePath}': {ex.Message}"); + } + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 91cdb7fff4..f2cbc5be3a 100644 --- a/index.json +++ b/index.json @@ -164,6 +164,11 @@ "file": "instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs", "title": "Instantiate two workbooks and copy all document properties from source to destination programmatically." }, + { + "category": "document-properties", + "file": "iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs", + "title": "Iterate through a directory of Excel files and update every DocumentVersion property to \"3.0\"." + }, { "category": "document-properties", "file": "load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs", From e91f6ac8ff23ce2da22fa42cf4bccf8c56d5cef9 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:19:26 +0500 Subject: [PATCH 35/47] Add example: create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet --- document-properties/agents.md | 1 + ...d-writes-them-into-a-metadata-worksheet.cs | 44 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 50 insertions(+) create mode 100644 document-properties/create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 4c29bcb60b..f47eabdf46 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -88,3 +88,4 @@ Output files are written to the working directory. - instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs - batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs - iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs +- create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs diff --git a/document-properties/create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs b/document-properties/create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs new file mode 100644 index 0000000000..6e2a170c58 --- /dev/null +++ b/document-properties/create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs @@ -0,0 +1,44 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsMetadataUtility +{ + class Program + { + static void Main(string[] args) + { + // Input and output file paths (adjust as needed) + string inputFile = "InputWorkbook.xlsx"; + string outputFile = "OutputWorkbook_WithMetadata.xlsx"; + + // Load the existing workbook (lifecycle: load) + Workbook workbook = new Workbook(inputFile); + + // Access the collection of custom document properties + CustomDocumentPropertyCollection customProps = workbook.CustomDocumentProperties; + + // Add a new worksheet named "Metadata" + Worksheet metadataSheet = workbook.Worksheets.Add("Metadata"); + + // Write header titles + metadataSheet.Cells["A1"].PutValue("Property Name"); + metadataSheet.Cells["B1"].PutValue("Property Value"); + + // Populate the worksheet with custom properties + int rowIndex = 1; // zero‑based index; row 1 is the second row (after header) + foreach (DocumentProperty prop in customProps) + { + metadataSheet.Cells[rowIndex, 0].PutValue(prop.Name); // Column A + metadataSheet.Cells[rowIndex, 1].PutValue(prop.Value); // Column B + rowIndex++; + } + + // Auto‑fit columns for better readability + metadataSheet.AutoFitColumns(); + + // Save the modified workbook (lifecycle: save) + workbook.Save(outputFile); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index f2cbc5be3a..ef9c004482 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs", "title": "Batch process all workbooks in a folder, setting each file's Language property to \"en-GB\"." }, + { + "category": "document-properties", + "file": "create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs", + "title": "Create a utility that reads custom properties from a workbook and writes them into a \"Metadata\" worksheet." + }, { "category": "document-properties", "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", From a71fb6ba302fe64b30b5180553af9074147332c9 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:20:54 +0500 Subject: [PATCH 36/47] Add example: generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file --- document-properties/agents.md | 1 + ...orkbooks-into-a-consolidated-excel-file.cs | 89 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 95 insertions(+) create mode 100644 document-properties/generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index f47eabdf46..c6197d3faf 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -89,3 +89,4 @@ Output files are written to the working directory. - batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs - iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs - create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs +- generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs diff --git a/document-properties/generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs b/document-properties/generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs new file mode 100644 index 0000000000..30eebafb36 --- /dev/null +++ b/document-properties/generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Aspose.Cells; + +namespace ConsolidatedSummaryReport +{ + class Program + { + static void Main() + { + try + { + // List of source workbook file paths + List sourceFiles = new List + { + @"C:\Data\Workbook1.xlsx", + @"C:\Data\Workbook2.xlsx", + @"C:\Data\Workbook3.xlsx" + // Add more paths as needed + }; + + // Create a new workbook that will hold the consolidated summary + Workbook summaryWorkbook = new Workbook(); + + // Use the first worksheet as the summary sheet + Worksheet summarySheet = summaryWorkbook.Worksheets[0]; + + // Write header row + summarySheet.Cells[0, 0].PutValue("Workbook"); + summarySheet.Cells[0, 1].PutValue("Property"); + summarySheet.Cells[0, 2].PutValue("Value"); + + int currentRow = 1; // start after header + + foreach (string filePath in sourceFiles) + { + // Skip missing files to avoid FileNotFoundException + if (!File.Exists(filePath)) + { + Console.WriteLine($"File not found: {filePath}"); + continue; + } + + try + { + // Load each source workbook + Workbook sourceWorkbook = new Workbook(filePath); + + // Get the file name for display + string workbookName = Path.GetFileName(filePath); + + // Iterate through built‑in document properties + foreach (var prop in sourceWorkbook.BuiltInDocumentProperties) + { + // Write workbook name, property name, and property value to the summary sheet + summarySheet.Cells[currentRow, 0].PutValue(workbookName); + summarySheet.Cells[currentRow, 1].PutValue(prop.Name); + summarySheet.Cells[currentRow, 2].PutValue(prop.Value?.ToString() ?? string.Empty); + currentRow++; + } + } + catch (Exception ex) + { + // Log errors for individual workbooks but continue processing others + Console.WriteLine($"Error processing '{filePath}': {ex.Message}"); + } + } + + // Ensure the output directory exists + string outputPath = @"C:\Data\ConsolidatedSummary.xlsx"; + string outputDir = Path.GetDirectoryName(outputPath); + if (!string.IsNullOrEmpty(outputDir) && !Directory.Exists(outputDir)) + { + Directory.CreateDirectory(outputDir); + } + + // Save the consolidated summary workbook + summaryWorkbook.Save(outputPath); + Console.WriteLine($"Consolidated summary saved to: {outputPath}"); + } + catch (Exception ex) + { + // Log any unexpected errors + Console.WriteLine($"Error: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index ef9c004482..8c6370327e 100644 --- a/index.json +++ b/index.json @@ -144,6 +144,11 @@ "file": "create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs", "title": "Create a workbook and set the Title built\u2011in property to a descriptive project name." }, + { + "category": "document-properties", + "file": "generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs", + "title": "Generate a summary report that aggregates built\u2011in property values from multiple workbooks into a consolidated Excel file." + }, { "category": "document-properties", "file": "instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs", From 0fc5275937c97e0b16b0ba834edf0e1aa687d1e1 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:22:00 +0500 Subject: [PATCH 37/47] Add example: validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format --- document-properties/agents.md | 1 + ...ing-the-workbook-to-any-external-format.cs | 54 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 60 insertions(+) create mode 100644 document-properties/validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index c6197d3faf..e6a475458b 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -90,3 +90,4 @@ Output files are written to the working directory. - iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs - create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs - generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs +- validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs diff --git a/document-properties/validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs b/document-properties/validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs new file mode 100644 index 0000000000..c82b68bb1b --- /dev/null +++ b/document-properties/validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs @@ -0,0 +1,54 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsExamples +{ + public class ValidateTitleBeforeExport + { + public static void Run() + { + try + { + // Create a new workbook instance + Workbook workbook = new Workbook(); + + // Access the built‑in document properties collection + BuiltInDocumentPropertyCollection props = workbook.BuiltInDocumentProperties; + + // Example: set the Title property (comment out to test validation failure) + // props.Title = "Sample Document Title"; + + // Validate that the Title property is not null or empty before exporting + string title = props.Title; + if (string.IsNullOrWhiteSpace(title)) + { + throw new InvalidOperationException("The workbook's Title property must be set before exporting."); + } + + // Export the workbook to PDF + PdfSaveOptions pdfOptions = new PdfSaveOptions + { + // Display the document title in the PDF window title bar + DisplayDocTitle = true + }; + + // Save the workbook + workbook.Save("ValidatedTitleExport.pdf", pdfOptions); + } + catch (Exception ex) + { + Console.Error.WriteLine($"Error: {ex.Message}"); + } + } + } + + // Entry point for the application + public class Program + { + public static void Main(string[] args) + { + ValidateTitleBeforeExport.Run(); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 8c6370327e..2a6a0494bd 100644 --- a/index.json +++ b/index.json @@ -309,6 +309,11 @@ "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", "title": "Open an Excel file and read the Author built\u2011in property to identify the creator." }, + { + "category": "document-properties", + "file": "validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs", + "title": "Validate that the Title built\u2011in property is not empty before exporting the workbook to any external format." + }, { "category": "save-workbook", "file": "create-a-workbook-populate-data-programmatically-and-export-it-as-a-tabdelimited-txt-file.cs", From 472eacfbc2c5cb255d3b10c4ab98db2732802dd4 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:23:45 +0500 Subject: [PATCH 38/47] Add example: use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs --- document-properties/agents.md | 1 + ...operties-and-display-the-number-in-logs.cs | 31 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 37 insertions(+) create mode 100644 document-properties/use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index e6a475458b..b8920a29ae 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -91,3 +91,4 @@ Output files are written to the working directory. - create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs - generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs - validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs +- use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs diff --git a/document-properties/use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs b/document-properties/use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs new file mode 100644 index 0000000000..3cb76484f2 --- /dev/null +++ b/document-properties/use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs @@ -0,0 +1,31 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Create a new workbook + Workbook workbook = new Workbook(); + + // Access the built‑in document properties collection (inherits DocumentPropertyCollection) + DocumentPropertyCollection builtInProps = workbook.BuiltInDocumentProperties; + + // Add a few custom properties to demonstrate counting + workbook.Worksheets.CustomDocumentProperties.Add("Author", "John Doe"); + workbook.Worksheets.CustomDocumentProperties.Add("Revision", 1); + workbook.Worksheets.CustomDocumentProperties.Add("Created", DateTime.Now); + + // Retrieve the total number of properties in each collection + int builtInCount = builtInProps.Count; + int customCount = workbook.Worksheets.CustomDocumentProperties.Count; + + // Output the counts to the console (log) + Console.WriteLine($"Built‑in document properties count: {builtInCount}"); + Console.WriteLine($"Custom document properties count: {customCount}"); + + // Optional: save the workbook + workbook.Save("DocumentPropertiesCount.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 2a6a0494bd..486e3181e8 100644 --- a/index.json +++ b/index.json @@ -309,6 +309,11 @@ "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", "title": "Open an Excel file and read the Author built\u2011in property to identify the creator." }, + { + "category": "document-properties", + "file": "use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs", + "title": "Use DocumentPropertyCollection to retrieve the total count of properties and display the number in logs." + }, { "category": "document-properties", "file": "validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs", From 2a13a0cd87c125869ffff6d21c4dc4cbf36cb327 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:24:29 +0500 Subject: [PATCH 39/47] Add example: compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing --- document-properties/agents.md | 1 + ...rate-a-list-of-differences-for-auditing.cs | 73 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 79 insertions(+) create mode 100644 document-properties/compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index b8920a29ae..74dfa27d36 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -92,3 +92,4 @@ Output files are written to the working directory. - generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs - validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs - use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs +- compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs diff --git a/document-properties/compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs b/document-properties/compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs new file mode 100644 index 0000000000..7f5b57746a --- /dev/null +++ b/document-properties/compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Paths to the two workbooks to compare + string workbookPath1 = "Workbook1.xlsx"; + string workbookPath2 = "Workbook2.xlsx"; + + // Load the workbooks (uses the Workbook(string) constructor) + Workbook wb1 = new Workbook(workbookPath1); + Workbook wb2 = new Workbook(workbookPath2); + + // Retrieve the custom document property collections + CustomDocumentPropertyCollection props1 = wb1.CustomDocumentProperties; + CustomDocumentPropertyCollection props2 = wb2.CustomDocumentProperties; + + // Prepare a list to hold audit messages + List differences = new List(); + + // Helper: create a dictionary for quick lookup of properties by name + var dict2 = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (DocumentProperty p in props2) + { + dict2[p.Name] = p; + } + + // Check for removed or modified properties + foreach (DocumentProperty p1 in props1) + { + if (!dict2.TryGetValue(p1.Name, out DocumentProperty p2)) + { + differences.Add($"Removed: '{p1.Name}' with value '{p1.Value}'"); + } + else + { + // Compare values (null‑safe) + string val1 = p1.Value?.ToString() ?? string.Empty; + string val2 = p2.Value?.ToString() ?? string.Empty; + if (!val1.Equals(val2, StringComparison.Ordinal)) + { + differences.Add($"Modified: '{p1.Name}' changed from '{val1}' to '{val2}'"); + } + // Remove the entry so that later we can detect additions + dict2.Remove(p1.Name); + } + } + + // Remaining entries in dict2 are properties that exist only in workbook2 (added) + foreach (var kvp in dict2) + { + DocumentProperty p = kvp.Value; + differences.Add($"Added: '{p.Name}' with value '{p.Value}'"); + } + + // Output the differences to console + Console.WriteLine("Custom Document Property Differences:"); + foreach (string diff in differences) + { + Console.WriteLine(diff); + } + + // Optionally, write the audit report to a text file + string reportPath = "CustomPropertiesAudit.txt"; + File.WriteAllLines(reportPath, differences); + Console.WriteLine($"Audit report saved to: {reportPath}"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 486e3181e8..cebbb034a2 100644 --- a/index.json +++ b/index.json @@ -134,6 +134,11 @@ "file": "batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs", "title": "Batch process all workbooks in a folder, setting each file's Language property to \"en-GB\"." }, + { + "category": "document-properties", + "file": "compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs", + "title": "Compare custom property sets between two workbooks and generate a list of differences for auditing." + }, { "category": "document-properties", "file": "create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs", From 29e72bc1d705cf56994a6b8ec30923822c25aa3a Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:25:16 +0500 Subject: [PATCH 40/47] Add example: remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries --- document-properties/agents.md | 1 + ...prefix-temp_-to-clean-temporary-entries.cs | 43 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 49 insertions(+) create mode 100644 document-properties/remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 74dfa27d36..8dcae3dc41 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -93,3 +93,4 @@ Output files are written to the working directory. - validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs - use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs - compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs +- remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs diff --git a/document-properties/remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs b/document-properties/remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs new file mode 100644 index 0000000000..1067386c6f --- /dev/null +++ b/document-properties/remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class RemoveTempCustomProperties +{ + static void Main() + { + // Paths for input and output workbooks + string inputPath = "input.xlsx"; + string outputPath = "output.xlsx"; + + // Load the workbook from the input file + using (FileStream stream = new FileStream(inputPath, FileMode.Open, FileAccess.Read)) + { + Workbook workbook = new Workbook(stream); + + // Access the custom document properties collection + CustomDocumentPropertyCollection customProps = (CustomDocumentPropertyCollection)workbook.Worksheets.CustomDocumentProperties; + + // Collect names of properties that start with "Temp_" + List namesToRemove = new List(); + foreach (DocumentProperty prop in customProps) + { + if (prop.Name.StartsWith("Temp_", StringComparison.OrdinalIgnoreCase)) + { + namesToRemove.Add(prop.Name); + } + } + + // Remove the identified properties + foreach (string name in namesToRemove) + { + customProps.Remove(name); + } + + // Save the cleaned workbook + workbook.Save(outputPath, SaveFormat.Xlsx); + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index cebbb034a2..3b3f44a6f3 100644 --- a/index.json +++ b/index.json @@ -314,6 +314,11 @@ "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", "title": "Open an Excel file and read the Author built\u2011in property to identify the creator." }, + { + "category": "document-properties", + "file": "remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs", + "title": "Remove all custom properties whose names start with the prefix \"Temp_\" to clean temporary entries." + }, { "category": "document-properties", "file": "use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs", From 14745d2ee2811e500805062b864f616e6f9b2fc6 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:25:54 +0500 Subject: [PATCH 41/47] Add example: add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content --- ...ing-tags-to-categorize-workbook-content.cs | 24 +++++++++++++++++++ document-properties/agents.md | 1 + index.json | 5 ++++ 3 files changed, 30 insertions(+) create mode 100644 document-properties/add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs diff --git a/document-properties/add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs b/document-properties/add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs new file mode 100644 index 0000000000..fb33664b7a --- /dev/null +++ b/document-properties/add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs @@ -0,0 +1,24 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // Create a new workbook + Workbook workbook = new Workbook(); + + // Define an array of tags to categorize the workbook content + string[] tags = new string[] { "Finance", "Quarterly", "Confidential" }; + + // Convert the string array to a single string (comma‑separated) for storage + string tagsValue = string.Join(",", tags); + + // Add a custom document property named "Tags" with the serialized array value + workbook.CustomDocumentProperties.Add("Tags", tagsValue); + + // Save the workbook to a file + workbook.Save("WorkbookWithTags.xlsx"); + } +} \ No newline at end of file diff --git a/document-properties/agents.md b/document-properties/agents.md index 8dcae3dc41..08d2bd9d5e 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -94,3 +94,4 @@ Output files are written to the working directory. - use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs - compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs - remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs +- add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs diff --git a/index.json b/index.json index 3b3f44a6f3..5638a3609a 100644 --- a/index.json +++ b/index.json @@ -129,6 +129,11 @@ "file": "update-the-text-direction-of-all-comments-in-a-worksheet-to-lefttoright-for-standard-layout.cs", "title": "Update the text direction of all comments in a worksheet to LeftToRight for standard layout." }, + { + "category": "document-properties", + "file": "add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs", + "title": "Add a custom property containing an array of string tags to categorize workbook content." + }, { "category": "document-properties", "file": "batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs", From aeadf7505b499a84ec1f03a592112d85953a2402 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:26:29 +0500 Subject: [PATCH 42/47] Add example: set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook --- document-properties/agents.md | 1 + ...iding-detailed-notes-about-the-workbook.cs | 27 +++++++++++++++++++ index.json | 5 ++++ 3 files changed, 33 insertions(+) create mode 100644 document-properties/set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 08d2bd9d5e..5d8781fca0 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -95,3 +95,4 @@ Output files are written to the working directory. - compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs - remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs - add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs +- set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs diff --git a/document-properties/set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs b/document-properties/set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs new file mode 100644 index 0000000000..4fe4a15d0c --- /dev/null +++ b/document-properties/set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs @@ -0,0 +1,27 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Properties; + +class SetWorkbookComments +{ + static void Main() + { + // Create a new workbook + Workbook workbook = new Workbook(); + + // Access the built‑in document properties collection + BuiltInDocumentPropertyCollection properties = workbook.BuiltInDocumentProperties; + + // Set a multiline comment using line breaks + properties.Comments = "This workbook was generated programmatically." + + Environment.NewLine + + "It contains sample data for demonstration purposes." + + Environment.NewLine + + "Author: John Doe" + + Environment.NewLine + + "Date: " + DateTime.Now.ToString("yyyy-MM-dd"); + + // Save the workbook to a file + workbook.Save("WorkbookWithComments.xlsx"); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 5638a3609a..ca8762dd8b 100644 --- a/index.json +++ b/index.json @@ -324,6 +324,11 @@ "file": "remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs", "title": "Remove all custom properties whose names start with the prefix \"Temp_\" to clean temporary entries." }, + { + "category": "document-properties", + "file": "set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs", + "title": "Set the built\u2011in Comments property to a multiline description providing detailed notes about the workbook." + }, { "category": "document-properties", "file": "use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs", From b55760ddc87432ddae847bb3b4efacc8eb3a92f0 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:27:11 +0500 Subject: [PATCH 43/47] Add example: read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index --- document-properties/agents.md | 1 + ...e-its-values-to-populate-a-search-index.cs | 63 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 69 insertions(+) create mode 100644 document-properties/read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 5d8781fca0..53969442ae 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -96,3 +96,4 @@ Output files are written to the working directory. - remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs - add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs - set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs +- read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs diff --git a/document-properties/read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs b/document-properties/read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs new file mode 100644 index 0000000000..31ce810a39 --- /dev/null +++ b/document-properties/read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using Aspose.Cells; + +namespace AsposeCellsKeywordSearchIndex +{ + class Program + { + static void Main() + { + // Create a new workbook and set the Keywords built‑in property + Workbook workbook = new Workbook(); + workbook.BuiltInDocumentProperties.Keywords = "Finance,Report,2024,Q1"; + + // Save the workbook (lifecycle rule: save) + string filePath = "KeywordWorkbook.xlsx"; + workbook.Save(filePath); + + // Load the saved workbook (lifecycle rule: load) + Workbook loadedWorkbook = new Workbook(filePath); + + // Read the Keywords property + string keywords = loadedWorkbook.BuiltInDocumentProperties.Keywords; + + // Prepare a simple in‑memory search index: + // The index maps each keyword to a list of file paths that contain it. + Dictionary> searchIndex = new Dictionary>(StringComparer.OrdinalIgnoreCase); + + // Split the keywords string (comma‑separated) and trim each entry + if (!string.IsNullOrEmpty(keywords)) + { + string[] keywordArray = keywords.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (string rawKeyword in keywordArray) + { + string keyword = rawKeyword.Trim(); + if (!searchIndex.ContainsKey(keyword)) + { + searchIndex[keyword] = new List(); + } + searchIndex[keyword].Add(filePath); + } + } + + // Demonstrate searching the index + Console.WriteLine("Search Index Contents:"); + foreach (var entry in searchIndex) + { + Console.WriteLine($"Keyword: '{entry.Key}' -> Files: {string.Join(", ", entry.Value)}"); + } + + // Example search: find all files containing the keyword "Report" + string searchTerm = "Report"; + if (searchIndex.TryGetValue(searchTerm, out List files)) + { + Console.WriteLine($"\nFiles containing keyword '{searchTerm}': {string.Join(", ", files)}"); + } + else + { + Console.WriteLine($"\nNo files found for keyword '{searchTerm}'."); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index ca8762dd8b..56ef6cd0a5 100644 --- a/index.json +++ b/index.json @@ -319,6 +319,11 @@ "file": "open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs", "title": "Open an Excel file and read the Author built\u2011in property to identify the creator." }, + { + "category": "document-properties", + "file": "read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs", + "title": "Read the Keywords built\u2011in property and use its values to populate a search index." + }, { "category": "document-properties", "file": "remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs", From 28f46855692e7c177e7c18c29f176e863be25a66 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:29:19 +0500 Subject: [PATCH 44/47] Add example: validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects --- document-properties/agents.md | 1 + ...hen-the-workbook-contains-chart-objects.cs | 60 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 66 insertions(+) create mode 100644 document-properties/validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 53969442ae..2205713cd3 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -97,3 +97,4 @@ Output files are written to the working directory. - add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs - set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs - read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs +- validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs diff --git a/document-properties/validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs b/document-properties/validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs new file mode 100644 index 0000000000..ca91e4c514 --- /dev/null +++ b/document-properties/validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs @@ -0,0 +1,60 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Charts; +using Aspose.Cells.Properties; + +class ValidateScaleCrop +{ + static void Main() + { + // Create a new workbook + Workbook workbook = new Workbook(); + + // Access the first worksheet + Worksheet sheet = workbook.Worksheets[0]; + + // Add sample data for a chart + sheet.Cells["A1"].PutValue("Category"); + sheet.Cells["A2"].PutValue("A"); + sheet.Cells["A3"].PutValue("B"); + sheet.Cells["B1"].PutValue("Value"); + sheet.Cells["B2"].PutValue(10); + sheet.Cells["B3"].PutValue(20); + + // Add a chart to the worksheet + int chartIdx = sheet.Charts.Add(ChartType.Column, 5, 0, 15, 5); + Chart chart = sheet.Charts[chartIdx]; + chart.NSeries.Add("B2:B3", true); + chart.NSeries.CategoryData = "A2:A3"; + + // Determine whether the workbook contains any chart objects + bool hasChart = false; + foreach (Worksheet ws in workbook.Worksheets) + { + if (ws.Charts.Count > 0) + { + hasChart = true; + break; + } + } + + // Access built‑in document properties + BuiltInDocumentPropertyCollection props = workbook.BuiltInDocumentProperties; + + if (hasChart) + { + // ScaleCrop must not be enabled when charts exist + Console.WriteLine("Workbook contains chart objects; ScaleCrop will remain disabled."); + props.ScaleCrop = false; + } + else + { + // No charts present, safe to enable ScaleCrop + props.ScaleCrop = true; + Console.WriteLine("ScaleCrop enabled: " + props.ScaleCrop); + } + + // Save the workbook + workbook.Save("ValidateScaleCrop.xlsx", SaveFormat.Xlsx); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 56ef6cd0a5..3f092ce822 100644 --- a/index.json +++ b/index.json @@ -339,6 +339,11 @@ "file": "use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs", "title": "Use DocumentPropertyCollection to retrieve the total count of properties and display the number in logs." }, + { + "category": "document-properties", + "file": "validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs", + "title": "Validate that ScaleCrop cannot be enabled when the workbook contains chart objects." + }, { "category": "document-properties", "file": "validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs", From a24c4df43de59c9f5aeaaed7317f99998166a118 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:30:00 +0500 Subject: [PATCH 45/47] Add example: log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable --- document-properties/agents.md | 1 + ...application-metadata-which-is-immutable.cs | 44 +++++++++++++++++++ index.json | 5 +++ 3 files changed, 50 insertions(+) create mode 100644 document-properties/log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 2205713cd3..04e578d0cb 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -98,3 +98,4 @@ Output files are written to the working directory. - set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs - read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs - validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs +- log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs diff --git a/document-properties/log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs b/document-properties/log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs new file mode 100644 index 0000000000..f1632ccc11 --- /dev/null +++ b/document-properties/log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs @@ -0,0 +1,44 @@ +using System; +using Aspose.Cells; +using Aspose.Cells.Metadata; +using Aspose.Cells.Properties; + +class Program +{ + static void Main() + { + // ------------------------------------------------------------ + // 1. Create a new workbook and save it to a physical file. + // ------------------------------------------------------------ + Workbook workbook = new Workbook(); + string filePath = "Sample.xlsx"; + workbook.Save(filePath); // lifecycle rule: create -> save + + // ------------------------------------------------------------ + // 2. Prepare metadata options for loading document properties. + // ------------------------------------------------------------ + MetadataOptions options = new MetadataOptions(MetadataType.DocumentProperties); + + // ------------------------------------------------------------ + // 3. Load the workbook metadata using the provided constructor. + // ------------------------------------------------------------ + WorkbookMetadata metadata = new WorkbookMetadata(filePath, options); // lifecycle rule: load + + // ------------------------------------------------------------ + // 4. Attempt to modify application metadata (NameOfApplication). + // In this scenario the application metadata is considered immutable, + // so we log a warning before performing the change. + // ------------------------------------------------------------ + Console.WriteLine("Warning: Attempting to modify immutable application metadata 'NameOfApplication'."); + + // Perform the modification (for demonstration purposes only). + metadata.BuiltInDocumentProperties.NameOfApplication = "MyApp"; + + // ------------------------------------------------------------ + // 5. Save the modified metadata back to the same file. + // ------------------------------------------------------------ + metadata.Save(filePath); // lifecycle rule: save + + Console.WriteLine("Metadata saved successfully."); + } +} \ No newline at end of file diff --git a/index.json b/index.json index 3f092ce822..3cca2a917f 100644 --- a/index.json +++ b/index.json @@ -254,6 +254,11 @@ "file": "load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs", "title": "Load an Excel file and verify that Language contains a valid .NET culture code." }, + { + "category": "document-properties", + "file": "log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs", + "title": "Log a warning whenever code attempts to modify application metadata, which is immutable." + }, { "category": "document-properties", "file": "open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs", From c5d917874cd0121a876b9cae5e621a1a9c8a5632 Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Wed, 20 May 2026 20:31:25 +0500 Subject: [PATCH 46/47] Add example: create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence --- document-properties/agents.md | 1 + ...ook-reloads-it-and-verifies-persistence.cs | 81 +++++++++++++++++++ index.json | 5 ++ 3 files changed, 87 insertions(+) create mode 100644 document-properties/create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs diff --git a/document-properties/agents.md b/document-properties/agents.md index 04e578d0cb..efea6f4247 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -99,3 +99,4 @@ Output files are written to the working directory. - read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs - validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs - log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs +- create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs diff --git a/document-properties/create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs b/document-properties/create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs new file mode 100644 index 0000000000..271d73b877 --- /dev/null +++ b/document-properties/create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs @@ -0,0 +1,81 @@ +using System; +using System.IO; +using System.Linq; +using Aspose.Cells; +using Aspose.Cells.Properties; + +namespace AsposeCellsTests +{ + public class CustomPropertyPersistenceTests + { + public void Run() + { + // Arrange: create a workbook and add a custom property + Workbook workbook = new Workbook(); + Worksheet sheet = workbook.Worksheets[0]; + const string propertyName = "TestProp"; + const string propertyValue = "TestValue"; + sheet.CustomProperties.Add(propertyName, propertyValue); + + // Temporary file for saving the workbook + string tempFile = Path.Combine(Path.GetTempPath(), $"CustomProp_{Guid.NewGuid()}.xlsx"); + + try + { + // Act: save the workbook + workbook.Save(tempFile); + + // Ensure the file exists before loading + if (!File.Exists(tempFile)) + throw new FileNotFoundException("Saved workbook not found.", tempFile); + + // Load the workbook back + Workbook loadedWorkbook = new Workbook(tempFile); + Worksheet loadedSheet = loadedWorkbook.Worksheets[0]; + + // Retrieve the custom property + CustomProperty loadedProperty = loadedSheet.CustomProperties + .FirstOrDefault(p => p.Name == propertyName); + + // Assert: property exists and value matches + if (loadedProperty == null) + throw new InvalidOperationException("Custom property was not found after loading the workbook."); + + if (!propertyValue.Equals(loadedProperty.Value?.ToString())) + throw new InvalidOperationException("Custom property value did not persist correctly."); + + Console.WriteLine("Custom property persisted successfully."); + } + catch (Exception ex) + { + // Runtime safety: log and rethrow + Console.WriteLine($"Error: {ex.Message}"); + throw; + } + finally + { + // Cleanup: delete temporary file if it exists + if (File.Exists(tempFile)) + { + try { File.Delete(tempFile); } catch { /* ignore cleanup errors */ } + } + } + } + } + + class Program + { + static void Main() + { + try + { + var test = new CustomPropertyPersistenceTests(); + test.Run(); + } + catch (Exception ex) + { + Console.WriteLine($"Test failed: {ex.Message}"); + } + } + } +} \ No newline at end of file diff --git a/index.json b/index.json index 3cca2a917f..bc7bf4e7e3 100644 --- a/index.json +++ b/index.json @@ -144,6 +144,11 @@ "file": "compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs", "title": "Compare custom property sets between two workbooks and generate a list of differences for auditing." }, + { + "category": "document-properties", + "file": "create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs", + "title": "Create a unit test that adds a custom property, saves the workbook, reloads it, and verifies persistence." + }, { "category": "document-properties", "file": "create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs", From 5860689edb7fbba3f5f182b4b7feaf492bb6db1c Mon Sep 17 00:00:00 2001 From: agent-aspose-cells-examples Date: Sun, 31 May 2026 18:54:28 +0500 Subject: [PATCH 47/47] Update agents.md --- document-properties/agents.md | 179 ++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 85 deletions(-) diff --git a/document-properties/agents.md b/document-properties/agents.md index efea6f4247..029a9cfccb 100644 --- a/document-properties/agents.md +++ b/document-properties/agents.md @@ -1,102 +1,111 @@ -# Document Properties Examples +--- +category: document-properties +framework: .NET +parent: ../agents.md +version: v2 +--- -This folder contains **Aspose.Cells for .NET** code examples related to: +# Persona -Document Properties +You are a C# developer specializing in document properties and metadata management using Aspose.Cells for .NET. +Generate simple, correct, production-quality examples that demonstrate ONE document-properties scenario at a time. -## Purpose +--- -These examples demonstrate common **Aspose.Cells APIs** used when working with: +# Scope -- Workbooks -- Worksheets -- Cells -- Formulas -- Charts -- Data operations +- Standalone .cs examples +- One operation per example +- Fully runnable with dotnet run +- No external dependencies +--- -## Example Files +# Required Namespaces -Each `.cs` file demonstrates a specific task related to **Document Properties**. +using System; +using Aspose.Cells; -Example: +--- -create-a-workbook.cs +# Key APIs +- BuiltInDocumentPropertyCollection +- CustomDocumentPropertyCollection +- Workbook.BuiltInDocumentProperties +- Workbook.CustomDocumentProperties -## Required Namespaces +--- -Most examples will require: +# Common Pattern -using Aspose.Cells; +1. Create workbook +2. Access document properties +3. Add, read, update, or remove properties +4. Save workbook +5. Print success message + +--- + +# Document Properties Rules + +- Use BuiltInDocumentProperties for standard metadata +- Use CustomDocumentProperties for user-defined metadata +- Use correct property data types +- One example = one document-properties operation + +--- + +# Input Strategy + +- Do NOT rely on external XLSX files +- Create workbook programmatically +- Keep examples self-contained + +--- + +# Output Rules + +- Always generate output.xlsx +- Ensure workbook is saved successfully +- Output files are written to the working directory + +--- + +# Common Tasks + +- Read built-in properties +- Add custom property +- Update property value +- Remove property +- Enumerate document properties + +--- + +# Common Mistakes + +❌ var workbook = new Workbook(); +✅ Workbook workbook = new Workbook(); + +❌ Store all values as strings +✅ Use appropriate property types + +❌ Workbook workbook = new Workbook("input.xlsx"); +✅ Workbook workbook = new Workbook(); + +--- + +# Code Simplicity + +- Keep examples concise +- Avoid unnecessary abstractions + +--- +# General Rules -## Common Pattern - -Typical Aspose.Cells workflow: - -Workbook workbook = new Workbook(); - -Worksheet sheet = workbook.Worksheets[0]; - -Cells cells = sheet.Cells; - - -## Output - -Examples may generate: - -- XLSX files -- PDF files -- CSV files -- Images - -Output files are written to the working directory. -- load-a-workbook-and-retrieve-the-title-builtin-property-for-verification.cs -- open-an-excel-file-and-read-the-author-builtin-property-to-identify-the-creator.cs -- instantiate-a-workbook-and-obtain-the-documentversion-builtin-property-to-check-version-information.cs -- load-a-spreadsheet-and-read-the-language-builtin-property-to-determine-locale-settings.cs -- open-a-workbook-and-query-the-scalecrop-builtin-property-to-view-image-scaling-flag.cs -- load-an-excel-document-and-inspect-the-linksuptodate-builtin-property-for-hyperlink-status.cs -- create-a-workbook-and-set-the-title-builtin-property-to-a-descriptive-project-name.cs -- open-a-file-and-update-the-author-builtin-property-with-the-correct-contributor-identifier.cs -- load-a-workbook-and-assign-the-documentversion-builtin-property-the-value-20.cs -- open-a-spreadsheet-and-set-the-language-builtin-property-to-fr-fr-for-localization.cs -- instantiate-a-workbook-and-enable-the-scalecrop-builtin-property-to-preserve-image-proportions.cs -- load-a-workbook-and-disable-the-linksuptodate-builtin-property-to-prevent-link-checks.cs -- open-a-workbook-and-add-a-custom-property-processeddate-with-the-current-datetime-value.cs -- load-an-excel-file-and-create-a-custom-property-projectid-with-an-integer-identifier.cs -- open-a-workbook-and-add-a-custom-boolean-property-isreviewed-set-to-true.cs -- load-a-workbook-locate-the-custom-property-projectid-and-update-its-integer-value.cs -- open-a-spreadsheet-and-remove-the-custom-property-isreviewed-to-clean-obsolete-metadata.cs -- load-a-workbook-and-check-whether-a-custom-property-clientname-exists-before-adding.cs -- open-a-file-and-iterate-through-all-builtin-properties-logging-each-name-and-value.cs -- load-a-workbook-and-enumerate-custom-properties-exporting-their-names-types-and-values-to-json.cs -- open-a-spreadsheet-and-filter-custom-properties-by-datetime-type-then-list-them.cs -- instantiate-two-workbooks-and-copy-all-document-properties-from-source-to-destination-programmatically.cs -- load-a-template-workbook-and-clone-its-builtin-properties-into-a-newly-created-workbook.cs -- open-a-workbook-and-validate-that-documentversion-matches-a-semantic-version-pattern-before-saving.cs -- load-an-excel-file-and-verify-that-language-contains-a-valid-net-culture-code.cs -- open-a-workbook-set-scalecrop-to-true-and-ensure-the-flag-persists-when-saving-as-pdf.cs -- instantiate-a-workbook-and-deliberately-access-a-nonexistent-builtin-property-to-demonstrate-exception-handling.cs -- load-a-spreadsheet-and-use-trycatch-to-safely-read-a-custom-property-reviewer.cs -- open-a-workbook-and-confirm-that-application-metadata-fields-appear-in-saved-file-properties.cs -- load-a-workbook-modify-several-properties-and-save-the-file-to-xlsx-format-preserving-changes.cs -- open-a-workbook-update-document-properties-and-export-the-result-to-csv-format-for-downstream-processing.cs -- instantiate-a-workbook-adjust-builtin-properties-and-save-the-document-as-pdf-to-embed-metadata.cs -- batch-process-all-workbooks-in-a-folder-setting-each-files-language-property-to-en-gb.cs -- iterate-through-a-directory-of-excel-files-and-update-every-documentversion-property-to-30.cs -- create-a-utility-that-reads-custom-properties-from-a-workbook-and-writes-them-into-a-metadata-worksheet.cs -- generate-a-summary-report-that-aggregates-builtin-property-values-from-multiple-workbooks-into-a-consolidated-excel-file.cs -- validate-that-the-title-builtin-property-is-not-empty-before-exporting-the-workbook-to-any-external-format.cs -- use-documentpropertycollection-to-retrieve-the-total-count-of-properties-and-display-the-number-in-logs.cs -- compare-custom-property-sets-between-two-workbooks-and-generate-a-list-of-differences-for-auditing.cs -- remove-all-custom-properties-whose-names-start-with-the-prefix-temp_-to-clean-temporary-entries.cs -- add-a-custom-property-containing-an-array-of-string-tags-to-categorize-workbook-content.cs -- set-the-builtin-comments-property-to-a-multiline-description-providing-detailed-notes-about-the-workbook.cs -- read-the-keywords-builtin-property-and-use-its-values-to-populate-a-search-index.cs -- validate-that-scalecrop-cannot-be-enabled-when-the-workbook-contains-chart-objects.cs -- log-a-warning-whenever-code-attempts-to-modify-application-metadata-which-is-immutable.cs -- create-a-unit-test-that-adds-a-custom-property-saves-the-workbook-reloads-it-and-verifies-persistence.cs +Refer to the root agents.md for: +- Boundaries +- Testing requirements +- Build and run instructions