只有你们才会帮我了 在windows窗体中的 DataGrid 怎样做才可以让他显示出 Excel表格的样式

猿猿粪 2004-09-02 09:50:03
我需要用DataGrid 生成一个10行的表格 不知道在 windows 窗体中是否可以实现
...全文
101 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
libra47 2004-09-13
  • 打赏
  • 举报
回复
private void BindReport()

{

DataSet ds=new DataSet();
myConnection.Open();
string strSql ="SELECT * from DsReward1 ";

if (strWhere!="")
strSql=strSql+" where "+strWhere;

SqlDataAdapter MyAdapter = new SqlDataAdapter(strSql,myConnection);
MyAdapter.Fill(ds);

DataView oView=new DataView(ds.Tables[0]);
DataGrid1.DataSource=oView;
DataGrid1.DataBind();
myConnection.Close();

Response.AddHeader("Content-Disposition", "attachment; filename=filename");
Response.Charset = "Default";
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState= false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
this.DataGrid1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End(); 

}
zfwdf 2004-09-02
  • 打赏
  • 举报
回复
可以

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧