上传文件
string savePath = Server.MapPath("~/upload/");//指定上传文件在服务器上的保存路径
//检查服务器上是否存在这个物理路径,如果不存在则创建
if (!System.IO.Directory.Exists(savePath))
{
System.IO.Directory.CreateDirectory(savePath);
}
if (FileUpload1.HasFile)
{
string fileExtension = Path.GetExtension(this.FileUpload1.FileName).ToLower();
string filename = DateTime.Now.ToOADate() + fileExtension;
savePath = savePath + filename;
FileUpload1.SaveAs(savePath);
string aller = string.Format("<a href='upload/{0}'>upload/{0}</a>", filename);
Response.Write(aller);
}
else
{
Response.Write("你还没有选择上传文件!");
}
Excel操作
var app = new Application { Visible = false };
Workbook workbook = app.Workbooks.Open(savePath);
Worksheet worksheet = app.Worksheets[1];