错了,直接作为数据源不行,有密码。
需要使用vba解密123,然后再用狐表的方法操作excel。
Dim fdialog As new OpenFileDialog
fdialog.Filter = "Excel文件(*.xls)|*.xls"
If fdialog.ShowDialog() = DialogResult.OK Then
Dim xlsapp As new Microsoft.Office.Interop.Excel.Application
Dim workbook As Object = xlsapp.Workbooks.Open(fdialog.FileName, _
Type.Missing, Type.Missing, Type.Missing, "123", Type.Missing, _
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, _
Type.Missing, Type.Missing, Type.Missing, Type.Missing)
workbook.Password = ""
workbook.SaveAs("d:\temp.xls")
xlsapp.Quit()
End If