日期:2014-05-18  浏览次数:20419 次

怎么打印页面中datagird中的内容
我想把页面中某个datagird中内容打印出来如何做呢?

------解决方案--------------------
参考 

http://blog.csdn.net/oec2003/archive/2008/03/06/2153817.aspx
------解决方案--------------------
导出到EXCEL打印
其他参考
http://topic.csdn.net/t/20040709/09/3158732.html
------解决方案--------------------
用CWSoft
------解决方案--------------------
C# code
/// <summary>
    /// 导出文件
    /// </summary>
    /// <param name="ExportType">导出类型</param>
    /// <param name="FileName">导出文件名</param>
    /// <remarks>导出类型可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档</remarks>
    private void Export(DataGrid grid,string ExportType, string FileName)
    {
        Response.Clear();
        Response.Buffer = true;
        Response.Charset = "GB2312";
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName);
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        Response.ContentType = ExportType;
        System.IO.StringWriter stringWriter = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(stringWriter);
        grid.RenderControl(htmlWriter);
        Response.Write(stringWriter.ToString());
        Response.End();
    }