1个回答
展开全部
public void btnTemplate_Click(object sender, EventArgs e)
{
string strResult = string.Empty;
string strPath = Server.MapPath("~/uploadfile/亏李"庆空掘);
string strFile = string.Format(@"{0}\{1}", strPath, "base.xls");
using (FileStream fs = new FileStream(strFile, FileMode.Open))
{
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("base.xls", System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
}
strPath你的模板存放路径,改一下。绝对靠誉核谱的,请采纳吧- -
{
string strResult = string.Empty;
string strPath = Server.MapPath("~/uploadfile/亏李"庆空掘);
string strFile = string.Format(@"{0}\{1}", strPath, "base.xls");
using (FileStream fs = new FileStream(strFile, FileMode.Open))
{
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("base.xls", System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
}
strPath你的模板存放路径,改一下。绝对靠誉核谱的,请采纳吧- -
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询