I am fairly new to VB.net and never used it for processing Office files. Right now I have to look at Excel file and send some emails based on the data in the cells. I do not need to write anything to these files. So far I have read quite a bit about PIAs and so far it looks that I have to design my application for particular Office version? Is there a way to write the application which could handle files created by different versions of MS Excel? I would like to be able to process these files without Office being installed on the computer at all, is there any way to do it?
我是VB.net的新手,从未用它来处理Office文件。现在我必须查看Excel文件并根据单元格中的数据发送一些电子邮件。我不需要为这些文件写任何东西。到目前为止,我已经阅读了很多关于PIA的内容,到目前为止看起来我必须为特定的Office版本设计我的应用程序?有没有办法编写可以处理由不同版本的MS Excel创建的文件的应用程序?我希望能够处理这些文件而不在计算机上安装Office,有什么办法吗?
3 个解决方案
#1
2
You could use Open XML SDK 2.0 for Microsoft Office link
您可以使用Open XML SDK 2.0 for Microsoft Office链接
#2
2
Don't need to install Office for getting data from excel file.
不需要安装Office以从excel文件获取数据。
But for getting data from EXCEL fileyou have to install OLEDB driver in your local machine as well as server if you are hosted your application on server.
但是要从EXCEL文件获取数据,如果您在服务器上托管应用程序,则必须在本地计算机和服务器中安装OLEDB驱动程序。
You can download OLEDB driver from MICROSOFT.
您可以从MICROSOFT下载OLEDB驱动程序。
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + YourEXCELFilePath + ";Extended Properties=Excel 12.0;")
con.Open()
atatable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
sheetname = datatable.Rows(0)("table_name").ToString
excelcomm = New OleDbCommand("select * from [" + sheetname + "]", con)
adexcel = New OleDbDataAdapter(excelcomm)
adexcel.Fill(Dataset)
After this code you will get excel sheet data in dataset.
在此代码之后,您将获得数据集中的Excel工作表数据。
Might this code can help you to get data from excel file.
可能这段代码可以帮助您从excel文件中获取数据。
(NOTE:this code is in vb.net)
(注意:此代码在vb.net中)
#1
2
You could use Open XML SDK 2.0 for Microsoft Office link
您可以使用Open XML SDK 2.0 for Microsoft Office链接
#2
2
Don't need to install Office for getting data from excel file.
不需要安装Office以从excel文件获取数据。
But for getting data from EXCEL fileyou have to install OLEDB driver in your local machine as well as server if you are hosted your application on server.
但是要从EXCEL文件获取数据,如果您在服务器上托管应用程序,则必须在本地计算机和服务器中安装OLEDB驱动程序。
You can download OLEDB driver from MICROSOFT.
您可以从MICROSOFT下载OLEDB驱动程序。
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + YourEXCELFilePath + ";Extended Properties=Excel 12.0;")
con.Open()
atatable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
sheetname = datatable.Rows(0)("table_name").ToString
excelcomm = New OleDbCommand("select * from [" + sheetname + "]", con)
adexcel = New OleDbDataAdapter(excelcomm)
adexcel.Fill(Dataset)
After this code you will get excel sheet data in dataset.
在此代码之后,您将获得数据集中的Excel工作表数据。
Might this code can help you to get data from excel file.
可能这段代码可以帮助您从excel文件中获取数据。
(NOTE:this code is in vb.net)
(注意:此代码在vb.net中)