打开Excel文件并检索数据 [英] Open Excel file and retrieve data
本文介绍了打开Excel文件并检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的PC中安装了Office 2003.通过vb.net代码,我想打开一个excel文件并从中检索数据.当我打开.xlsx文件时,它工作正常,但是当我打开.xlsx文件时,它将引发异常.
Hello Everyone,
I have got office 2003 installed in my pc. through vb.net code I want to open an excel file and retrieve data from it. When I open and .xls file it works fine but when I open .xlsx file it throws an exception.
Dim excelApp As Microsoft.Office.Interop.Excel.Application = Nothing
Dim wb As Microsoft.Office.Interop.Excel.Workbook = Nothing
Dim intUnload As DialogResult
Dim strPath As String = "C:\Documents and Settings\Administrator\My Documents\"
Dim sfdlg As New OpenFileDialog()
sfdlg.InitialDirectory = strPath
sfdlg.Filter = "Microsot Office Excel Workbook (*.xls;*.xlsx)|*.xls;*.xlsx" 'All files (*.*)|*.*"
intUnload = sfdlg.ShowDialog()
If intUnload = Windows.Forms.DialogResult.OK Then
intCount = 0
InitialiseDataEntry()
pbRecords.Visible = True
pbRecords.BringToFront()
pbRecords.Position = 10 : Application.DoEvents()
strPath = sfdlg.FileName
excelApp = New Microsoft.Office.Interop.Excel.Application
wb = excelApp.Workbooks.Open(strPath)
End If
谁能帮助我如何在装有Office 2003的PC中打开.xlsx文件?
在此先感谢您.
Can anyone help me out how to open .xlsx file in a pc having office 2003 installed?
Thanks in advance.
推荐答案
Office 2003默认情况下无法打开* .xslx文件.您需要安装Office兼容性包才能使Excel 2003能够打开这些文件.您可以在这里下载:
http://www.microsoft.com/downloads/zh-CN/details.aspx?displaylang = en& FamilyID = 941b3470-3ae9-4aee-8f43-c6bb74cd1466 [
Office 2003 can''t open *.xslx files by default. You need to install the Office Compatibility Pack to enable Excel 2003 to open these files. You can download it here:
http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=941b3470-3ae9-4aee-8f43-c6bb74cd1466[^]
EPPlus [ ^ ]允许您读写excel文件-它是开源的,也可以从asp.net应用程序中使用.
问候
Espen Harlinn
EPPlus[^] allows you to read and write excel files - it''s open source and can be used from asp.net applications too.
Regards
Espen Harlinn
这篇关于打开Excel文件并检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文