Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi,
im uploading .xls file. but i want to check whether the file im uploading consist productname and price(this r 2 header), then only it should upload. otherwise it shouldnot....can anybody send the code using vb.net. How i am uploading .xls file add next code how 2 check?

please reply
thanks in adv.

VB
Protected Sub UploadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
      If (FileUpLoad1.HasFile And FileUpLoad2.HasFile) Then
          FileUpLoad1.SaveAs("C:\Documents and Settings\Administrator\My Documents\anil\" + FileUpLoad1.FileName)
          Label1.Text = "File Uploaded: "; + FileUpLoad1.FileName
          FileUpLoad2.SaveAs("C:\Documents and Settings\Administrator\My Documents\anil\"; + FileUpLoad2.FileName)         
 Label2.Text = "File Uploaded:" + FileUpLoad2.FileName
      Else
          Label1.Text =  "No File Uploaded."
          Label2.Text = " No File Uploaded."
      End If
  End Sub
Posted
Updated 17-Mar-10 4:25am
v3

1 solution

Of course, this won't work, because your web application root is surely not under your my documents, and unless this machine will be your web server, it's not likely that this path will exist on the server.

You could also check the extension first, but you can use the Microsoft Tools For Office to examine your spreadsheet. I believe you can also use ADO.NET to select data from an Excel spreadsheet. Of course, Excel will need to be installed on your server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900