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) |
Each section stores its cells in one (or both) of the following ways:
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)) |
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) |