Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.
Thu Sep 29, 2011 9:51 am
Hello,
I have a problem with a file, it mentions an error on opening.
- Code: Select all
The argument specified was not within the range of valid values. Err.Number = 5
Here is the code, can you help me, thank you in advance.
- Code: Select all
Dim workbook As Workbook = New Workbook()
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "Excel 2007|*.xlsx"
openFileDialog1.Title = "Ouvrir une importation"
If openFileDialog1.ShowDialog() = DialogResult.OK Then
' Assign the cursor in the Stream to the Form's Cursor property.
M_sfile = openFileDialog1.FileName
End If
Try
workbook.LoadFromFile(M_sfile, ExcelVersion.Version2010)
Catch ex As Exception
Console.WriteLine(Err.Description)
Console.WriteLine(Err.Number)
End Try
Dim sheet As Worksheet = workbook.Worksheets(0)
Guy Muller
-
gmuller@vonet.ch
-
- Posts: 8
- Joined: Wed Mar 23, 2011 10:58 am
Fri Sep 30, 2011 3:52 am
Hello,Guy Muller
Sorry for any inconveniences caused by us and thank you for your patience with our reply.
I have tested the Err.number which is always within the range of valid values. Err.Number = 5. You can have a try the following code:
- Code: Select all
Dim filename As String
Dim workbook As New Workbook()
Dim openDlg As New OpenFileDialog()
openDlg.Filter = "Excel 2007|*.xlsx|All Files|*.*"
openDlg.Title = "Ouvrir une inportation"
If openDlg.ShowDialog() = DialogResult.OK Then
filename = openDlg.FileName
Try
workbook.LoadFromFile(filename, ExcelVersion.Version2007)
Catch ex As Exception
Console.WriteLine(Err.Description)
Console.WriteLine(Err.Number)
End Try
Dim worksheet As Worksheet = workbook.Worksheets(0)
worksheet.Range("A1").Text = "Hello,World"
workbook.SaveToFile("..\..\Test.xlsx")
System.Diagnostics.Process.Start("..\..\Test.xlsx")
End If
If you still have any question, please contact us.
Tina
Technical Support/Developer,
e-iceblue Support Team
-
Tina.Lin
-
- Posts: 152
- Joined: Tue Sep 13, 2011 5:37 am