Gets a list with the names of the worksheets in a Microsoft Excel (.XLS) file.
Namespace:
C1.Win.C1FlexGridAssembly: C1.Win.C1FlexGrid.2 (in C1.Win.C1FlexGrid.2.dll)
Syntax
| C# |
|---|
public string[] LoadExcelSheetNames( string fileName ) |
| Visual Basic |
|---|
Public Function LoadExcelSheetNames ( _ fileName As String _ ) As String() |
Parameters
- fileName
- Type: System..::..String
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.
Examples
The code below loads all sheets in an Excel workbook into a collection of grids in a
TabControl:
Copy CodeC#
// 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); } |