Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / File Operations / Saving Data to a File / Adding Custom Properties
In This Topic
    Adding Custom Properties
    In This Topic

    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.

    1. Open the Properties dialog.  

      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.

    2. Add custom properties to the Properties dialog.

    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:

    • In the Name list, select a name from the list.
    • In the Type list, select the data type for the property to be added.
    • In the Value box, type a value for the property.
      The value that you type must match the selection in the Type list. For example, if you select a Number in the Type list, you must type a number in the Value box.

    ii. Click Add.
    The custom property gets added to the Properties table.

    Modify/ Delete Custom Properties

    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.