• [转]简单的动态修改RDLC报表页边距和列宽的方法


    本文转自:http://star704983.blog.163.com/blog/static/136661264201161604413204/

    1.修改页边距

    XmlDocument XMLDoc = new XmlDocument();
    XMLDoc.Load(System.Windows.Forms.Application.StartupPath + @"Report_try-2.rdlc");
    XmlNamespaceManager xmn = new XmlNamespaceManager(XMLDoc.NameTable);
    xmn.AddNamespace("X", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
    string strXPath;
    strXPath = "/X:Report/X:Page/X:LeftMargin"; 
    XmlNode Node = XMLDoc.SelectSingleNode(strXPath, xmn).ChildNodes.Item(0);     // 读取左边距
    Node.InnerText = "20mm";      // 左边距改为20mm
    XMLDoc.Save(System.Windows.Forms.Application.StartupPath + @"Report_try-2.rdlc");  // 写XML
     
    修改右、上、下边距方法和上述方法一样,只需要更改 strXPath = "/X:Report/X:Page/X:LeftMargin"; 
     
    2.修改表格列宽
    XmlDocument XMLDoc = new XmlDocument();
    XMLDoc.Load(System.Windows.Forms.Application.StartupPath + @"Report_try-2.rdlc");
    XmlNamespaceManager xmn = new XmlNamespaceManager(XMLDoc.NameTable);
    xmn.AddNamespace("X", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
    string strXPath;
    strXPath = "/X:Report/X:Body/X:ReportItems/X:Tablix/X:TablixBody";
    XmlNodeList NDList = XMLDoc.SelectSingleNode(strXPath, xmn).ChildNodes;
    XmlNode subNode = NDList.Item(0);
    /*
    subNode.ChildNodes.Count即为报表列数
    subNode.ChildNodes.Item(X).innerText即为第X列的列宽,X下标从0开始
    */
    subNode.ChildNodes.Item(0).InnerText = "20mm";     // 修改第一列列宽为20mm
    XMLDoc.Save(System.Windows.Forms.Application.StartupPath + @"Report_try-2.rdlc");  // 写XML
  • 相关阅读:
    整数划分递归模板
    最近点对算法模板
    计算几何模板
    poj1269---直线位置关系
    poj1017----模拟
    MVC 提交List 集合 注意对应的参数名称
    使用 WebClient 來存取 GET,POST,PUT,DELETE,PATCH 網路資源
    对路径访问拒绝,要加上具体filename/c.png
    sql 列集合
    百度地图 Infowidow 内容(content 下标签) 点击事件
  • 原文地址:https://www.cnblogs.com/freeliver54/p/9599253.html
Copyright © 2020-2023  润新知