首页 > 其他 > 详细

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

时间:2018-09-06 17:47:52      阅读:484      评论:0      收藏:0      [点我收藏+]

本文转自: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

 

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

原文:https://www.cnblogs.com/freeliver54/p/9599253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!