FlexGrid for WinForms
LoadExcelSheetNames Method
Example 



Name of the Excel file, including the path.
Gets a list with the names of the worksheets in a Microsoft Excel (.XLS) file.
Syntax
'Declaration
 
Public Function LoadExcelSheetNames( _
   ByVal fileName As String _
) As String()
'Usage
 
Dim instance As C1FlexGridBase
Dim fileName As String
Dim value() As String
 
value = instance.LoadExcelSheetNames(fileName)
public string[] LoadExcelSheetNames( 
   string fileName
)
public:
array<String^>^ LoadExcelSheetNames( 
   String^ fileName
) 

Parameters

fileName
Name of the Excel file, including the path.

Return Value

An array containing the names of the worksheets defined in the file.
Remarks
This method is used to obtain a list of sheet names that can later be used to load and save specific sheets using the LoadExcel(String,String,FileFlags) and SaveExcel(String,String,FileFlags,PrinterSettings) methods.
Example
The code below loads all sheets in an Excel workbook into a collection of grids in a TabControl:
// clear tabControl
tabControl.TabPages.Clear();
            
// load sheet names
string fileName = "c:\book1.xls";
string[] sheets = _flexGrid.LoadExcelSheetNames(fileName);
            
// load each sheet
foreach (string sheetName in sheets)
{
  // create a new grid for this sheet
  C1FlexGrid flex = new C1FlexGrid();
  flex.Dock = DockStyle.Fill;
  
  // load sheet into new grid
  flex.LoadExcel(fileName, sheetName);
  
  // add grid to the tabControl
  TabPage page = new TabPage();
  page.Controls.Add(flex);
  page.Text = sheetName;
  tabControl.TabPages.Add(page);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

C1FlexGridBase Class
C1FlexGridBase Members

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback