Framework / Presentation Layer / Formula Sheet / Formula Sections

In This Topic
    Formula Sections
    In This Topic

    The formula sections are represented by instances of the NFormulaSection class. You can think of formula sections as groups, which group related cells. The sections of a sheet are contained in an instance of the NFormulaSectionCollection class, which can be obtained from the Sections property of the NFormulaSheet class. The following example creates a sheet and adds a section in it:

    C#
    Copy Code
    // create a new sheet and get its sections
    NFormulaSheet sheet = new NFormulaSheet();
    // create a section with the specified name and title
    NFormulaSection section = new NFormulaSection("MySection", "My First Section");
    // add the section to the sheet
    sheet.Sections.Add(section);
    
    Visual Basic
    Copy Code
    ' create a new sheet
    Dim sheet As New NFormulaSheet
    ' create a section with the specified name and title
    Dim section As New NFormulaSection("MySection", "My First Section")
    ' add the section to the sheet
    sheet.Sections.Add(section)
    
     Section Name and Title
    Each section has a name and a title, which are accessible from the Name and Title properties respectively. The section name is used as a prefix when you want to explicitly specify the section in which a named cell resides (see Formula Cell References for more information). The section title is used when the formula section is visually edited.
     Section Cells

    Each section stores its cells in one (or both) of the following ways:

    • Named Section Cells - the named section cells are stored in an instance of the NFormulaCellDictionary class, which can be obtained from the Cells property. The named section cells, can be referenced by other cells formulas by their name. The following example adds several named cells to a section:
      C#
      Copy Code
      // create the section cells dictionary and add two cells
      section.Cells = new NFormulaCellDictionary();
      section.Cells.Add("Cell1", new NSingleFormulaCell(10));
      section.Cells.Add("Cell2", new NSingleFormulaCell(20));
      
      Visual Basic
      Copy Code
      ' create the section cells dictionary and add two cells
      section.Cells = New NFormulaCellDictionary
      section.Cells.Add("Cell1", New NSingleFormulaCell(10))
      section.Cells.Add("Cell2", New NSingleFormulaCell(20))
      
    • Section Rows - the rows of a section are contained in an instance of the NFormulaRowCollection class, which can be obtained from the Rows property. You can add and remove NFormulaRow instances from this collection. Formula rows are in fact collections of formula cells. The formula rows form an irregular grid (since rows can have a different number of cells). The following example adds several rows to a section:
      C#
      Copy Code
      // create the rows collection
      section.Rows = new NFormulaRowCollection();
      // add a row with two cells
      NFormulaRow row1 = new NFormulaRow();
      row1.Add(new NSingleFormulaCell(10));
      row1.Add(new NSingleFormulaCell(20));
      section.Rows.Add(row1); 
      // add a row with three cells
      NFormulaRow row2 = new NFormulaRow();
      row2.Add(new NSingleFormulaCell(10));
      row2.Add(new NSingleFormulaCell(20));
      row2.Add(new NSingleFormulaCell(30));
      section.Rows.Add(row2);
      
      Visual Basic
      Copy Code
      ' create the rows collection
      section.Rows = New NFormulaRowCollection
      ' add a row with two cells
      Dim row1 As New NFormulaRow
      row1.Add(New NSingleFormulaCell(10))
      row1.Add(New NSingleFormulaCell(20))
      section.Rows.Add(row1)
      ' add a row with three cells
      Dim row2 As New NFormulaRow
      row2.Add(New NSingleFormulaCell(10))
      row2.Add(New NSingleFormulaCell(20))
      row2.Add(New NSingleFormulaCell(30))
      section.Rows.Add(row2)
      
      The cells inside rows, can be referenced by other cells formulas with an identifier, which is a concatenation of the section name, cell column name and row index. See Formula Cell References for more information.
     Section Verbs
    Visually the formula sections are edited with verbs. The verbs, which the section supports can be obtained from the GetVerbs method of the NFormulaSection class. Besides the section the rows inside it can also provide verbs for visual editing - they are consistently retrieved from the the GetVerbs method of the NFormulaRow class.
    See Also