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
npoi
epplus
which do not require excel