通过C#编写代码
调用SqlServer中存储过程
将查询出的结果到出到Excel!
应该如何写代码
请高手指点一下?
多谢了!!!
调用SqlServer中存储过程
将查询出的结果到出到Excel!
应该如何写代码
请高手指点一下?
多谢了!!!
解决方案 »
- 有简单一点的方法吗?Linq该如何写呢?
- 在listview控件中选取多个项目后,项目数量始终为0
- 关于C#winform的问题
- 高分送:Server Error in '/' Application
- 【请问如何清空一个数组】~~~~~~~~~~~~~~~~~~~`国庆快乐,中秋快乐,UP有分~~~~
- 请问文本框的TextChanged事件判断输入的字符是否规范?
- 写入文件没有权限 帮忙 急!
- active directory 编程(使用DirectoryEntry和DirectorySearcher)中奇怪的错误,有用过AD的高手请指点,100分献上
- 用.net 安装 Windows 服务 出错
- winXP和win7的界面都正常,win8下不正常,什么情况
- 如何连接Access数据库,然后显示数据到DataGridView
- dateset数据如何导入WORD请大家指点
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "utf-8";
string Filename = Typename + ".xls";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "online;filename=" + Filename);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.ContentType = "application/ms-excel";
//this.EnableViewState = false;
HttpContext.Current.Response.Write(TempHtml);
HttpContext.Current.Response.End();
}Typename 文件名
TempHtml 将数据配置成HTML字符串放到这个字符串里
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=boyd_Reporter.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter=new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter=new System.Web.UI.HtmlTextWriter(oStringWriter);
this.Boyd_Dg1.Font.Size=10; //设置输出报表文字大小为10号,偏小
this.Boyd_Dg1.BorderStyle=System.Web.UI.WebControls.BorderStyle.Double;
this.Boyd_Dg1.BorderColor=Color.Black;
this.Boyd_Dg1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Response.Buffer= true;
Response.Charset= "GB2312 ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename=boyd_Reporter.xls ");
Response.ContentEncoding=System.Text.Encoding.GetEncoding( "GB2312 ");//设置输出流为简体中文
Response.ContentType = "application/ms-excel ";//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo( "ZH-CN ",true);
System.IO.StringWriter oStringWriter=new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter=new System.Web.UI.HtmlTextWriter(oStringWriter);
this.Boyd_Dg1.Font.Size=10; //设置输出报表文字大小为10号,偏小
this.Boyd_Dg1.BorderStyle=System.Web.UI.WebControls.BorderStyle.Double;
this.Boyd_Dg1.BorderColor=Color.Black;
this.Boyd_Dg1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();