Spread Windows Forms 10.0 Product Documentation
OpenExcel(String,Int32) Method
Example 


Path and name of the file to open
Index of the sheet to load from the file
Opens an Excel file and loads the specified sheet (by number) from that file into this sheet.
Syntax
'Declaration
 
Public Overloads Function OpenExcel( _
   ByVal fileName As String, _
   ByVal excelSheetIndex As Integer _
) As Boolean
'Usage
 
Dim instance As SheetView
Dim fileName As String
Dim excelSheetIndex As Integer
Dim value As Boolean
 
value = instance.OpenExcel(fileName, excelSheetIndex)
public bool OpenExcel( 
   string fileName,
   int excelSheetIndex
)

Parameters

fileName
Path and name of the file to open
excelSheetIndex
Index of the sheet to load from the file

Return Value

Boolean: true if successful; false otherwise
Example
This example open an Excel file and loads it in the active sheet.
OpenFileDialog ofd = new OpenFileDialog();
string s;
ofd.Filter = "Excel files (*.xls)|*.xls";
ofd.FilterIndex = 2;
ofd.InitialDirectory = Application.StartupPath;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK) 
{
    s = ofd.FileName;
    fpSpread1.ActiveSheet.OpenExcel(s, 0);
}
Dim s As String
Dim ofd As New OpenFileDialog()
ofd.Filter = "Excel files (*.xls)|*.xls"
ofd.FilterIndex = 2
ofd.InitialDirectory = Application.StartupPath
ofd.RestoreDirectory = True
If ofd.ShowDialog() = DialogResult.OK Then
    s = ofd.FileName
    FpSpread1.ActiveSheet.OpenExcel(s, 0)
End If
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

SheetView Class
SheetView Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.