Custom properties are metadata fields that you can add to a workbook to describe its content, purpose, or other relevant information. You can add text, date, or numeric values to custom properties and choose a custom name from a list of suggested names. You can also assign them the values yes or no.
To add additional custom properties, you can use the CustomDocumentProperties object of the IDocumentProperties Interface. It represents all the custom properties of the workbook.
Spread Designer also provides you an option for custom properties of the workbook in the File > Properties > Custom tab.
Custom properties can be added by code or using the ribbonBar at runtime. To do so, follow the steps below.
Using Code
C# Copy Code// Open dialog using code FarPoint.Win.Spread.Dialogs.BuiltInDialogs.DocumentProperties(fpSpread1.AsWorkbook());
VB Copy Code' Open dialog using code FarPoint.Win.Spread.Dialogs.BuiltInDialogs.DocumentProperties(FpSpread1.AsWorkbook())
Using RibbonBar
i. Run the code below to attach the ribbonBar with fpSpread.
C# Copy Code ribbonBar1.Attach(fpSpread1);
VB Copy Code ribbonBar1.Attach(FpSpread1)
ii. Open the File menu.
iii. Select Properties. The Properties dialog appears.
Using Code
The following example code shows how to add custom properties to the Properties dialog.
C# Copy Code // Add properties using code fpSpread1.AsWorkbook().CustomDocumentProperties.Add("Client", GrapeCity.Core.DocumentPropertyType.Boolean, true); fpSpread1.AsWorkbook().CustomDocumentProperties.Add("Date completed", GrapeCity.Core.DocumentPropertyType.Date, new System.DateTime(2023, 3, 12)); fpSpread1.AsWorkbook().CustomDocumentProperties.Add("Document number", GrapeCity.Core.DocumentPropertyType.Number, 123); fpSpread1.AsWorkbook().CustomDocumentProperties.Add("Language", GrapeCity.Core.DocumentPropertyType.String, "English"); FarPoint.Win.Spread.Dialogs.BuiltInDialogs.DocumentProperties(fpSpread1.AsWorkbook());
VB Copy Code ' Add properties using code FpSpread1.AsWorkbook().CustomDocumentProperties.Add("Client", GrapeCity.Core.DocumentPropertyType.[Boolean], True) FpSpread1.AsWorkbook().CustomDocumentProperties.Add("Date completed", GrapeCity.Core.DocumentPropertyType.[Date], New DateTime(2023, 3, 12)) FpSpread1.AsWorkbook().CustomDocumentProperties.Add("Document number", GrapeCity.Core.DocumentPropertyType.Number, 123) FpSpread1.AsWorkbook().CustomDocumentProperties.Add("Language", GrapeCity.Core.DocumentPropertyType.[String], "English") FarPoint.Win.Spread.Dialogs.BuiltInDialogs.DocumentProperties(FpSpread1.AsWorkbook())
Using RibbonBar
i. Click on the Custom tab and provide the following details:
ii. Click Add.
The custom property gets added to the Properties table.
Spread also allows you to edit or delete an existing custom property as per your requirement. To make changes, select the property name from the Properties table, make the necessary edits, and then click the Modify button to save the changes. Similarly, you may delete an unwanted custom property by selecting the property name and then clicking the Delete button.
Spread allows the user to add identifier information to a worksheet called custom properties. CustomProperties are used to store additional metadata or information related to the worksheet. To add custom properties to a worksheet, use the CustomProperties property of the IWorksheet interface. You can add the CustomProperties to a worksheet only programmatically.
You can also use Add/Delete method of CustomProperties for adding/removing the metadata to a worksheet.
Consider the following example code to add and delete the identifier information at worksheet level.
C# |
Copy Code
|
---|---|
IWorksheet sheet = fpSpread1.AsWorkbook().ActiveSheet; object[,] properties = new object[,] { { "Department", 3 }, { "Editor", "Serena"}, { "Project", "Spread"}, { "Status", true} }; for (int i = 0; i < 4; i++) { sheet.CustomProperties.Add(properties[i, 0].ToString(), properties[i, 1]); } sheet.CustomProperties[0].Delete(); sheet.CustomProperties[0].Delete(); Console.WriteLine(sheet.CustomProperties[0].Name); Console.WriteLine(sheet.CustomProperties[1].Name); |
Visual Basic |
Copy Code
|
---|---|
Dim sheet As IWorksheet = FpSpread1.AsWorkbook().ActiveSheet Dim properties As Object(,) = New Object(,) { {"Department", 3}, {"Editor", "Serena"}, {"Project", "Spread"}, {"Status", True}} For i As Integer = 0 To 4 - 1 sheet.CustomProperties.Add(properties(i, 0).ToString(), properties(i, 1)) Next sheet.CustomProperties(0).Delete() sheet.CustomProperties(0).Delete() Console.WriteLine(sheet.CustomProperties(0).Name) Console.WriteLine(sheet.CustomProperties(1).Name) |