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

≡放荡痞女 提交于 2020-01-03 17:05:40

问题


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?


回答1:


You could use Open XML SDK 2.0 for Microsoft Office link




回答2:


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

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.

You can download OLEDB driver from MICROSOFT.

 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.

Might this code can help you to get data from excel file.

(NOTE:this code is in vb.net)




回答3:


you can use

  1. npoi

  2. epplus

    which do not require excel



来源:https://stackoverflow.com/questions/23419834/how-to-process-excel-file-in-vb-net-without-office-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!