Read Data From Excel sheet using Excel.Application Object
Read Data from excel we can use odbe connection string. if that excel sheet is protected by password.Even through if know the password also you cann't connect to it by using odbe or oledb connection strings.
we can overcome this by using Excel.Application object which is present in microsoft excel 11.0 object library(com componect)
VB code:
First add reference->Com->Microsoft Excel 11.0 Object Library.
Dim xlapp As New Excel.Appication Dim wb As Excel.Workbook Dim ws As Excel.Worksheet wb=xlapp.Workbooks.Open(yourexcelfilepath,,,,password) ws=wb.Sheets("sheet1") ws.Cells(0,0)//to display perticular cell value ws.rows.count//to find row count, ws.columns.count//to find columns count. xlapp.Visible=True
|
No responses found. Be the first to respond and make money from revenue sharing program.
|