Upload and read data in Excel

Source: Internet
Author: User

Recently, an old system was maintained. One of the functions is to upload an Excel file, read data for maintenance, and then insert it into the SQL database.
The following insus. net uses the Asp.net standard upload control:

 
<ASP: fileuploadID= "Fileupload1"Runat= "Server" />

 
Insus. Net is a habit of creating a temporary directory in every project.


Most of the time, we can process some temporary files or data in this temporary directory. It is a bit like a temporary directory in windows.

 


In the above code example, first obtain the uploaded file name, which contains the path;
Next, we will know the upload extension;
The third line of code uses the guid class method newguid () to combine a new file name with the extension.
The fourth line of code creates the target path of the uploaded file.
The last step is save.

The following shows how to read Excel Data and bind it to the gridview control:

 

#80 lines of code in the above sample code, can refer to the "Asp.net read Excel file 2" http://www.cnblogs.com/insus/archive/2011/05/05/2037808.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.