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