Loading client Excel file into a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I need to enable the IE user to upload/select a file .Then i have to
validate the data and put it in a grid/table .
Using input type=file will save it on the server where there is no need for
it .

Br
Ornez
 
Dim xlApp As Excel.Application

Dim xlBook As Excel.Workbook

Dim xlSheet1 As Excel.Worksheet

' Start Excel and get Application object.

'xlApp = CreateObject("Excel.Application")

xlApp = New Excel.Application

' Get a new workbook.

xlBook = xlApp.Workbooks.Open(strFile)

xlSheet1 = xlBook.Worksheets(1)

Dim strSheet As String

strSheet = xlSheet1.Name

'close everything

xlSheet1 = Nothing

xlBook.Close()

xlBook = Nothing

xlApp = Nothing

Dim con As New OleDbConnection

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strFile & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""

con.Open()

Dim dtbl As New DataTable

Dim dad As New OleDbDataAdapter("SELECT * FROM [" & strSheet & "$] WHERE
LEN(Number) > 0", con)

Try

dad.Fill(dtbl)
 
Back
Top