已有56人关注
gridview
发表在C#图书答疑 2009-06-29
是否精华
版块置顶:
  我按照
分享到:
精彩评论 11
zm307755214
学分:0 LV1
2009-06-30
沙发
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF7;
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("Settlement_Searching_History.xls", System.Text.Encoding.UTF8).ToString());
        Response.ContentType = "application/ms-excel";
        this.EnableViewState = false;

        StringWriter tw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(tw);
        GridView1.RenderControl(hw);
        Response.Write(tw.ToString());
        Response.Flush();
        Response.End();
    public override void VerifyRenderingInServerForm(Control control) { }
zm307755214
学分:0 LV1
2009-06-30
板凳
   
小科_mrkj
学分:43 LV2
2009-06-30
地板
读者朋友:
    您好,运行这个例子后,应该是弹出一个对话框,您需要首先单击“保存”按钮,保存这个excel文件。
zm307755214
学分:0 LV1
2009-06-30
4L
  如果我点保存,保存之后,再打开,提示不能读取文件,

  如果弹出对话框直接点打开就提示,不能读取文件。
小科_mrkj
学分:43 LV2
2009-06-30
5L
读者朋友:
    您好,这个例子我试过了,是好使的啊,你直接运行光盘中的源程序看一下效果,然后再检查一下你写的代码是不是那块出现错误了。
zm307755214
学分:0 LV1
2009-06-30
6L
 我是按书上敲的,根书上没有不同, 

  你帮忙看下,那数据源那是不是地方写错了。 
        Report report = new Report();
        System.Data.DataTable  dt = report.Get_Settlement_Searching_History(fromdate, todate, customer_code, source).Tables[0];
        this.GridView1.DataSource = dt;
        this.GridView1.DataBind();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF7;
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode   ("Settlement_Searching_History.xls", System.Text.Encoding.UTF8).ToString());
        Response.ContentType = "application/ms-excel";
        this.EnableViewState = false;

        StringWriter tw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(tw);
        GridView1.RenderControl(hw);
        Response.Write(tw.ToString());
        Response.Flush();
        Response.End();

    public override void VerifyRenderingInServerForm(Control control) { }

   这是 我的代码,帮忙看下有没有错    , ,,,  
    
                    谢谢了
小科_mrkj
学分:43 LV2
2009-07-01
7L
读者朋友:
    您好,我们这台回复问题的机器跟我们工作的机器连不上,请你再看一下光盘中的代码时候能够正常运行,如果出现问题,可以把问题写上,我们再看一下。
zm307755214
学分:0 LV1
2009-07-01
8L
  我也想看了,

  我
小科_mrkj
学分:43 LV2
2009-07-03
9L
读者朋友:
    您好,您的代码写的应该是对的,请问你用的是那本书中的代码。
zm307755214
学分:0 LV1
2009-07-04
10L
  都是自己把那控件从另一个界面COPY过来的,

  里面控件的属性 visible设置成了false
   
    所以就出现了这个问题

   瞎折腾这么久。。。 
首页上一页 12 下一页尾页 11 条记录 1/2页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照