简体   繁体   中英

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

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?

您可以使用Open XML SDK 2.0 for Microsoft Office 链接

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)

you can use

  1. npoi

  2. epplus

    which do not require excel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM