Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Read Excel Data
Author:
Nagendra Peruru
E-mail:
Click to e-mail author
Submitted:
7/15/2005
Version:
VB6
Compatibility:
VB6
Category:
Miscellaneous
Views:
113705
There is a Procedure to Read Excel data in Easiest way. Once u read the data it is easy to insert into database.
Declarations:
Lib Reference: Microsoft Excel 11.0 Object Library ' If u not found 11.0 u can fined lower version Dim WithEvents xlBook As Excel.Workbook ' Declare it on Top
Code:
' Write This in Any command button 'Here U mention ur Excel File name Set xlBook = GetObject(App.Path & "\SampleData.xls") xlBook.Application.Visible = True xlBook.Windows(1).Visible = True xlBook.Application.WindowState = xlMinimized Dim irow As Integer Dim jcol As Integer 'There r 3 rows X 3 columns in excel sheet For irow = 2 To 4 For icol=1 to 3 msgbox xlBook.Worksheets(1).Cells(irow, icol).Value next next 'Create this is an excel sheet and We have rows and ' colums like this Data is started from 2nd row so we 'mentioned in First for loop starts from 2 to till 4 ' 1st col 2nd col 3rd col ' sno name sal 1st row ' 1 Nagendra 223 2nd row ' 2 Magdhum 223 3rd row ' 3 Bhaskar 223 4th row
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement