vb.net 如何在没有安装office的情况下在vb.net中处理excel文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23419834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:30:00  来源:igfitidea点击:

How to process excel file in vb.net without office installed

vb.netexcelms-office

提问by user2824519

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 的情况下处理这些文件,有什么办法吗?

回答by 0cool

You could use Open XML SDK 2.0 for Microsoft Office link

您可以将 Open XML SDK 2.0 用于 Microsoft Office链接

回答by Kaushal Khamar

Don't need to install Office for getting data from excel file.

从 Excel 文件中获取数据不需要安装 Office。

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 中)

回答by Bender

you can use

您可以使用

  1. npoi

  2. epplus

    which do not require excel

  1. 网名

  2. 埃普拉斯

    不需要excel