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 new file mode 100644 index 0000000000..029a9cfccb --- /dev/null +++ b/document-properties/agents.md @@ -0,0 +1,111 @@ +--- +category: document-properties +framework: .NET +parent: ../agents.md +version: v2 +--- + +# Persona + +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. + +--- + +# Scope + +- Standalone .cs examples +- One operation per example +- Fully runnable with dotnet run +- No external dependencies + +--- + +# Required Namespaces + +using System; +using Aspose.Cells; + +--- + +# Key APIs + +- BuiltInDocumentPropertyCollection +- CustomDocumentPropertyCollection +- Workbook.BuiltInDocumentProperties +- Workbook.CustomDocumentProperties + +--- + +# Common Pattern + +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 + +Refer to the root agents.md for: +- Boundaries +- Testing requirements +- Build and run instructions 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 e6b002cd9b..73520eeee1 100644 --- a/index.json +++ b/index.json @@ -2944,6 +2944,106 @@ "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": "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", + "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-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", + "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", + "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", + "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", + "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", + "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", + "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": "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", + "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", + "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", + "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", + "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",