//保存EXCEL到SERVER上
private void SaveExcel(HSSFWorkbook wb,string path,string fileName)
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
FileStream fs = new FileStream(path+fileName, FileMode.Create, FileAccess.ReadWrite);
wb.Write(fs);
fs.Close();
}
//下载SERVER上的EXCEL
private void DownLoadExcel(string path,string fileName)
{
//"http://" + HttpContext.Current.Request.Url.Host + "/Resource/tempdata/fn.xls";
//"http://" + HttpContext.Current.Request.Url.Host+":"+HttpContext.Current.Request.Url.Port + "/Resource/tempdata/fn.xls";
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename="+HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8));
Response.TransmitFile(path + fileName);
}
浙公网安备 33010602011771号