// If this directory does not exist, create this directory
If ( ! System. Io. Directory. exists (_ filepath )) {
System. Io. Directory. createdirectory (_ filepath );
}
// Save the file to the specified location on the server
Try {
Fileupload1.saveas (_ filename );
Response. Redirect (String. Format ("Commentdetail. aspx? Filename = {0}", _ Filename ));
} Catch (Exception exp) {
ThrowExp;
}
}
}
Read Excel # Region Read Excel
/**/ /// <Summary>
/// Read Excel documents
/// </Summary>
/// <Param name = "path"> File Name </Param>
/// <Returns> Returns a dataset. </Returns>
/// Http://dev.csdn.net/article/72/72658.shtm
Public Static Dataset exceltods ( String Path) {
If ( ! String . Isnullorempty (PATH )) {
String Strconn = " Provider = Microsoft. Jet. oledb.4.0; " + " Data Source = " + Path + " ; " + " Extended properties = Microsoft Excel 8.0; " ;
Oledbconnection Conn = New Oledbconnection (strconn );
Conn. open ();
String Strexcel = "" ;
Oledbdataadapter mycommand = Null ;
Dataset DS = Null ;
Strexcel = " Select * from [sheet1 $] " ;
Mycommand = New Oledbdataadapter (strexcel, strconn );
DS = New Dataset ();
Mycommand. Fill (DS );
Return DS;
}
Return Null ;
}
# Endregion
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.