asp.net读取EXcel的小讨论
在CS文件中,首先在顶部引入操作Excel数据的命名空间
using System.Data.OleDb;
正式代码如下:
private void Button_Click(object sender, System.EventArgs e)
{
string thefullname = this.uploadFile.PostedFile.FileName;//获取完整路径
ClientScriptManager csm = Page.ClientScript;
if (thefullname == "")
{
csm.RegisterStartupScript(GetType, "Error", "alert('请选择要上传得Excel文件');", true);
return;
}
int fileLength = this.uploadFile.PostedFile.ContentLength;
if (fileLength > 512000)
{
csm.RegisterStartupScript(GetType, "Error", "alert('文件已超过500K,无法上传!');", true);
return;
}
FileInfo info = new FileInfo(thefullname);
string fileExt = info.Extension;
if (fileExt.ToLower() != ".xls")
{
csm.RegisterStartupScript(GetType, "Error", "alert('不是Excel文件,请使用正确的文件格式!');", true);
return;
}
string uploadPath = Page.MapPath(@"uploadfile\report.xls");
 
相关文档:
TreeView 控件具有许多不同的外观,从而可以提供灵活的图像自定义以及指定自定义用户界面 (UI) 选项的属性。您可以将图像与 TreeView 控件一起使用来表示节点、连接线以及展开和折叠图标。还可以使用 ImageSet 属性中一组预定义的图像,或者通过设置各个图像属性来使用自定义图像。
&nbs ......
//2007年4月24日
this.TextBox6.Text = System.DateTime.Now.ToString("D");
//2007-4-24
this.TextBox7.Text = System.DateTime.Now.ToString("d");
//2007年4月24日 16:30:15
this. ......
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
  ......
代码:
/// <summary>
/// 打开Excel文件
/// </summary>
/// <param name="ExcelFileName">文件名</param>
private void OpenExcelFile(string ExcelFileName)
{
&nb ......
出处:天极网 作者:朱先忠编译 时间:2006-9-25 9:36:00
一、简介
在上篇中我们详细分析过,.NET框架2.0版本提供了一个新的命名空间(System.Net.Mail)和一些发送电子邮件的新类(注意:.NET框架1.x版本中提供的命名空间System.Web.Mail及相关的类仍然可以使用,以实现向后兼容性)。而且,我们 ......