See Also

INames Members  | SpreadsheetGear Namespace  | Names Property  | Names Property  | IName Interface

Requirements

Namespace: SpreadsheetGear

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: SpreadsheetGear (in SpreadsheetGear.dll)

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Requirements Languages SpreadsheetGear The Performance Spreadsheet Component Company 

INames Interface

SpreadsheetGear Namespace : INames Interface

Represents the collection of defined names in a workbook or worksheet.

For a list of all members of this type, see INames members.

Syntax

[Visual Basic]
<DefaultMemberAttribute("Item")> Public Interface INames
[C#]
[DefaultMemberAttribute("Item")] public interface INames
[C++]
[DefaultMemberAttribute("Item")] public __gc __interface INames
[C++/CLI]
[DefaultMemberAttribute("Item")] public interface class INames

Example

[C#] 

class Program 

    static void Main() 
    { 
        // Create a workbook. 
        SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); 
        // Get the worksheet and change the name. 
        SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"]; 
        worksheet.Name = "2005 Sales"; 
        // Get the worksheet cells reference. 
        SpreadsheetGear.IRange cells = worksheet.Cells; 
        // Add column headers. 
        cells["B1"].Formula = "Jan"; 
        cells["C1"].Formula = "Feb"; 
        cells["D1"].Formula = "Mar"; 
        // Add row headers. 
        cells["A2"].Formula = "Jennifer"; 
        cells["A3"].Formula = "William"; 
        cells["A4"].Formula = "Kristen"; 
        // Add random data. 
        cells["B2:D4"].Formula = "=RAND()*10000"; 
        // Center the column headers. 
        cells["B1:D1"].HorizontalAlignment = SpreadsheetGear.HAlign.Center; 
        // Bold the row and column headers. 
        cells["B1:D1,A2:A4"].Font.Bold = true; 
        // Add defined names. 
        SpreadsheetGear.INames names = workbook.Names; 
        names.Add("Jan", "='2005 Sales'!$B$2:$B$4"); 
        names.Add("Feb", "='2005 Sales'!$C$2:$C$4"); 
        names.Add("Mar", "='2005 Sales'!$D$2:$D$4"); 
        names.Add("Sales", "='2005 Sales'!$B$2:$D$4"); 
        // Format sales data as currency. 
        cells["Sales"].NumberFormat = "$#,##0"; 
        // Sum each month. 
        cells["B5"].Formula = "=SUM(Jan)"; 
        cells["C5"].Formula = "=SUM(Feb)"; 
        cells["D5"].Formula = "=SUM(Mar)"; 
        // Format sums. 
        cells["B5:D5"].NumberFormat = "$#,##0"; 
        // Write the workbook. 
        workbook.SaveAs(@"C:\2005 Sales.xls", SpreadsheetGear.FileFormat.XLS97); 
    } 

    

[Visual Basic] 

Class Program
    Shared Sub Main()
        ' Create a workbook.
        Dim workbook As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook()
        ' Get the worksheet and change the name.
        Dim worksheet As SpreadsheetGear.IWorksheet = workbook.Worksheets("Sheet1")
        worksheet.Name = "2005 Sales"
        ' Get the worksheet cells reference.
        Dim cells As SpreadsheetGear.IRange = worksheet.Cells
        ' Add column headers.
        cells("B1").Formula = "Jan"
        cells("C1").Formula = "Feb"
        cells("D1").Formula = "Mar"
        ' Add row headers.
        cells("A2").Formula = "Jennifer"
        cells("A3").Formula = "William"
        cells("A4").Formula = "Kristen"
        ' Add random data.
        cells("B2:D4").Formula = "=RAND()*10000"
        ' Center the column headers.
        cells("B1:D1").HorizontalAlignment = SpreadsheetGear.HAlign.Center
        ' Bold the row and column headers.
        cells("B1:D1,A2:A4").Font.Bold = True
        ' Add defined names.
        Dim names As SpreadsheetGear.INames = workbook.Names
        names.Add("Jan", "='2005 Sales'!$B$2:$B$4")
        names.Add("Feb", "='2005 Sales'!$C$2:$C$4")
        names.Add("Mar", "='2005 Sales'!$D$2:$D$4")
        names.Add("Sales", "='2005 Sales'!$B$2:$D$4")
        ' Format sales data as currency.
        cells("Sales").NumberFormat = "$#,##0"
        ' Sum each month.
        cells("B5").Formula = "=SUM(Jan)"
        cells("C5").Formula = "=SUM(Feb)"
        cells("D5").Formula = "=SUM(Mar)"
        ' Format sums.
        cells("B5:D5").NumberFormat = "$#,##0"
        ' Write the workbook.
        workbook.SaveAs("2005 Sales.xls", SpreadsheetGear.FileFormat.XLS97)
    End Sub 'Main
End Class 'Program

Requirements

Namespace: SpreadsheetGear

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: SpreadsheetGear (in SpreadsheetGear.dll)

See Also

INames Members  | SpreadsheetGear Namespace  | Names Property  | Names Property  | IName Interface

 

 


See our live Excel Reporting, Excel Charting, Excel to DataGrid and Excel Calculation Samples.

Copyright © 2003-2007 SpreadsheetGear LLC. All Rights Reserved.

SpreadsheetGear and Spreadsheet Gear are trademarks of SpreadsheetGear LLC.