- string fileURL="d://test.xls";
- System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileURL);
- Response.Clear();
- Response.AddHeader("content-disposition", "attachment;filename=" + Server.UrlEncode(fileInfo.Name.ToString()));
- Response.AddHeader("content-length", fileInfo.Length.ToString());
- Response.ContentType = "application/octet-stream";
- Response.Charset = "gb2312";
- Response.ContentEncoding = Encoding.UTF8;
- Response.WriteFile(fileURL);
- Response.Flush();
- Response.End();
- StringWriter sw = new StringWriter();
- string str = "12t34t56thah";
- sw.WriteLine(str);
- 输出到Excel
- Response.Clear();
- Response.AddHeader("Content-disposition", "attachment;filename="+filename+".xls");
- //Response.ContentEncoding = Encoding.GetEncoding("gb2312");
- Response.ContentEncoding = Encoding.UTF8;
- Response.ContentType = "application/ms-excel";
- Response.Charset = "gb2312";
- Response.Write(sw.ToString());
- sw.Close();
- Response.Flush();
- Response.End();