• 动态RDLC报表(五)


    动态RDLC报表类DynamicReport:数据表节点数据填充

           数据表部分是最麻烦的,可以添加多个数据表,可以设置多维表头,可以设置多字段的统计行,不同的列可以采用不同的样式。在传入数据表前需要先传入列样式、多维表头,数据表和统计列是同一时间传入的,页眉和页脚则需要在数据表后传入。

           在这里最多可以设置三行表头,从上到下依次是hearderTop、hearderMerge和数据表中的列。表头的样式包含如下几部分:

            public string ColoumName { get; set; }     //列名
            public float ColoumWidth { get; set; }       //列宽
            public TextAlign TextAlign { get; set; }      //对齐
            public ConsoleColor ConsoleColor { get; set; }    //颜色
            public Boolean IsShortDate { get; set; }       //显示短日期格式

           多维表头的数据表结构是:

                DataTable hearderMerge = new DataTable();
                hearderMerge.Columns.Add("CellNumber", Type.GetType("System.Int32"));
                hearderMerge.Columns.Add("CellValue", Type.GetType("System.String"));


           CellNumber代表占用多少列宽度,1为一列,2为合并二列,总列数不能超过或少过数据表的列数;CellValue就是显示的名称。

            统计行可以是单列或多列,以string方式传入,不同列用逗号分隔,如“列名1,列名3”,可以是任意列,可以相邻或间隔,但必须是数据表中存在的列并且值可以相加。当只有一列统计时在此列的前面显示“统计:”,如果是第一列则不显示。

           数据表会生成DataSets节点和Tablix节点。

    1. private List<ReportColoumStyle> _coloumStyle = new List<ReportColoumStyle>();
    2. internal const float ColoumWidth = 1.6F; //列宽
    3. private float tabelTopPosition = 0.0F;
    4. private DataTable hearderName = new DataTable();
    5. private DataTable hearderMerge = new DataTable();
    6. private DataTable hearderTop = new DataTable();
    7. public void SetColoumStyle(List<ReportColoumStyle> coloumStyle)
    8. {
    9. this._coloumStyle = coloumStyle;
    10. }
    11. public void AddData(DataTable dataTable, string totalColumn)
    12. {
    13. if (dataTable != null && dataTable.Rows.Count > 0)
    14. {
    15. var coloumNames = new List<string>();
    16. foreach (DataColumn dataColumn in dataTable.Columns)
    17. {
    18. var protertyName = dataColumn.ColumnName;
    19. coloumNames.Add(protertyName);
    20. }
    21. AddReportItemPattern(coloumNames.ToArray(), dataTable, totalColumn);
    22. }
    23. }
    24. protected void AddReportItemPattern(string[] coloumNames, dynamic data, string totalColumn = "")
    25. {
    26. StringBuilder fields = new StringBuilder();
    27. StringBuilder coloums = new StringBuilder();
    28. StringBuilder tablixHearders = new StringBuilder();
    29. StringBuilder tablixCells = new StringBuilder();
    30. StringBuilder tablixMembers = new StringBuilder();
    31. float currentNamePrefix = _reportItemPatterns.Count + _reportHeadPatterns.Count + 1;
    32. float tableWidth = 0F;
    33. float dataRows = ((DataTable)data).Rows.Count; //数据行数
    34. int totalNumber = 0;
    35. string totalWidth = "";
    36. string totalCellPattern = "";
    37. string totalMemberPattern = "";
    38. string mergeMemberPattern = "";
    39. Boolean isHearderMerge = true;
    40. float hearderHeight = 0.0F;
    41. foreach (var coloumName in coloumNames)
    42. {
    43. var coloumWidth = ColoumWidth;
    44. var textAlign = TextAlign.Right;
    45. var consoleColor = ConsoleColor.Black;
    46. var isShortDate = false;
    47. var reportColoumStyle = _coloumStyle.FirstOrDefault(r => r.ColoumName == coloumName);
    48. if (reportColoumStyle != null)
    49. {
    50. textAlign = reportColoumStyle.TextAlign;
    51. coloumWidth = reportColoumStyle.ColoumWidth;
    52. consoleColor = reportColoumStyle.ConsoleColor;
    53. isShortDate = reportColoumStyle.IsShortDate;
    54. }
    55. tableWidth += coloumWidth;
    56. if (totalColumn != "")
    57. {
    58. if (totalColumn.Split(',').Length > 1)
    59. {
    60. for (int i = 0; i < totalColumn.Split(',').Length; i++)
    61. {
    62. if (totalColumn.Split(',')[i] == coloumName)
    63. {
    64. if (totalWidth == "")
    65. {
    66. totalWidth = totalNumber.ToString();
    67. }
    68. else
    69. {
    70. totalWidth += "," + totalNumber.ToString();
    71. }
    72. }
    73. }
    74. }
    75. else
    76. {
    77. if (totalColumn == coloumName)
    78. {
    79. totalWidth = totalNumber.ToString();
    80. }
    81. }
    82. }
    83. totalNumber += 1;
    84. var bottomBorder = string.Empty; //每个单元格底部border
    85. if (dataRows == 0)
    86. {
    87. bottomBorder = "<BottomBorder><Style>NoneStyle>BottomBorder>";
    88. }
    89. var coloumValue = coloumName;
    90. if (hearderName.Rows.Count > 0)
    91. {
    92. foreach (DataColumn dc in hearderName.Columns)
    93. {
    94. if (dc.ColumnName == coloumName)
    95. {
    96. if (hearderName.Rows[0][coloumName].ToString().Trim() != "") coloumValue = hearderName.Rows[0][coloumName].ToString();
    97. }
    98. }
    99. }
    100. //例外,如果coloumName包含Coloum之类的字段,则将value设成空
    101. if (coloumName.IndexOf("Column", System.StringComparison.Ordinal) > -1)
    102. {
    103. coloumValue = " ";
    104. }
    105. fields.AppendFormat(
    106. "<Field Name=\"{0}\"><DataField>{0}DataField><rd:TypeName>System.Stringrd:TypeName>Field>",
    107. coloumName);
    108. coloums.AppendFormat("<TablixColumn><Width>{0}cmWidth>TablixColumn>", coloumWidth);
    109. if (hearderMerge.Rows.Count > 0)
    110. {
    111. if (isHearderMerge)
    112. {
    113. hearderHeight += 0.5F;
    114. mergeMemberPattern = "<TablixMember><KeepWithGroup>AfterKeepWithGroup><RepeatOnNewPage>trueRepeatOnNewPage>TablixMember>";
    115. if (hearderTop.Rows.Count > 0)
    116. {
    117. hearderHeight += 0.5F;
    118. mergeMemberPattern += "<TablixMember><KeepWithGroup>AfterKeepWithGroup><RepeatOnNewPage>trueRepeatOnNewPage>TablixMember>";
    119. }
    120. isHearderMerge = false;
    121. GetHearderMerge(tablixHearders, currentNamePrefix);
    122. }
    123. tablixHearders.AppendFormat("<TablixCell><CellContents>" +
    124. "<Textbox Name=\"Textbox{0}{1}\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether><Paragraphs><Paragraph>" +
    125. "<TextRuns><TextRun><Value>{2}Value><Style><FontWeight>BoldFontWeight><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    126. "<rd:DefaultName>Textbox{0}{1}rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border><TopBorder><Style>NoneStyle>TopBorder><VerticalAlign>MiddleVerticalAlign>" +
    127. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>",
    128. coloumName, currentNamePrefix, coloumValue, bottomBorder);
    129. }
    130. else
    131. {
    132. tablixHearders.AppendFormat("<TablixCell><CellContents>" +
    133. "<Textbox Name=\"Textbox{0}{1}\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether><Paragraphs><Paragraph>" +
    134. "<TextRuns><TextRun><Value>{2}Value><Style><FontWeight>BoldFontWeight><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    135. "<rd:DefaultName>Textbox{0}{1}rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border>{3}<VerticalAlign>MiddleVerticalAlign>" +
    136. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>",
    137. coloumName, currentNamePrefix, coloumValue, bottomBorder);
    138. }
    139. //string valueString = "=IIf(IIf(Fields!{0}.Value=\"True\",\"√\", Fields!{0}.Value)=\"False\",\"\",IIf(Fields!{0}.Value=\"True\",\"√\", Fields!{0}.Value))";
    140. string valueString = "=Fields!{0}.Value";
    141. if (isShortDate) valueString = "=FormatDateTime(Fields!{0}.Value,DateFormat.ShortDate)";
    142. tablixCells.AppendFormat(
    143. "<TablixCell><CellContents><Textbox Name=\"{0}{1}1\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    144. "<Paragraphs><Paragraph><TextRuns><TextRun><Value>" + valueString + "Value><Style><Color>{3}Color><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>{2}TextAlign>Style>Paragraph>Paragraphs>" +
    145. "<rd:DefaultName>{0}{1}1rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border><VerticalAlign>MiddleVerticalAlign>" +
    146. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>",
    147. coloumName, currentNamePrefix, textAlign, consoleColor);
    148. tablixMembers.AppendFormat("<TablixMember />");
    149. }
    150. if (totalColumn != "")
    151. {
    152. totalCellPattern = "<TablixRow><Height>0.5cmHeight><TablixCells>\r\n\r\n";
    153. if (totalColumn.Split(',').Length > 1)
    154. {
    155. for (int i = 0; i < totalColumn.Split(',').Length; i++)
    156. {
    157. if (i == 0)
    158. {
    159. for (int n = 0; n < Convert.ToInt32(totalWidth.Split(',')[i]); n++)
    160. {
    161. totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"total" + _reportItemPatterns.Count.ToString() + i.ToString() + n + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    162. "<Paragraphs><Paragraph><TextRuns><TextRun><Value /><Style>NoneStyle>TextRun>TextRuns><Style><TextAlign>LeftTextAlign>Style>Paragraph>Paragraphs>" +
    163. "<rd:DefaultName>total" + _reportItemPatterns.Count.ToString() + i.ToString() + n + "rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    164. "<PaddingLeft>0ptPaddingLeft><PaddingRight>0ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>0ptPaddingBottom>Style>Textbox>CellContents>TablixCell>\r\n\r\n";
    165. }
    166. }
    167. else
    168. {
    169. for (int n = 0; n < (Convert.ToInt32(totalWidth.Split(',')[i]) - Convert.ToInt32(totalWidth.Split(',')[i - 1]) - 1); n++)
    170. {
    171. totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"total" + _reportItemPatterns.Count.ToString() + i.ToString() + n + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    172. "<Paragraphs><Paragraph><TextRuns><TextRun><Value /><Style>NoneStyle>TextRun>TextRuns><Style><TextAlign>LeftTextAlign>Style>Paragraph>Paragraphs>" +
    173. "<rd:DefaultName>total" + _reportItemPatterns.Count.ToString() + i.ToString() + n + "rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    174. "<PaddingLeft>0ptPaddingLeft><PaddingRight>0ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>0ptPaddingBottom>Style>Textbox>CellContents>TablixCell>\r\n\r\n";
    175. }
    176. }
    177. totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"totalValue" + _reportItemPatterns.Count.ToString() + i.ToString() + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    178. "<Paragraphs><Paragraph><TextRuns><TextRun><Value>=Sum(CDec(Fields!" + totalColumn.Split(',')[i] + ".Value))Value><Style><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize><FontWeight>BoldFontWeight>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    179. "<rd:DefaultName>totalValue" + _reportItemPatterns.Count.ToString() + i.ToString() + "rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    180. "<PaddingLeft>0ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>\r\n\r\n";
    181. }
    182. for (int i = 1; i < (coloumNames.Length - Convert.ToInt32(totalWidth.Split(',')[totalWidth.Split(',').Length - 1])); i++)
    183. {
    184. totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"totalall" + _reportItemPatterns.Count.ToString() + i.ToString() + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    185. "<Paragraphs><Paragraph><TextRuns><TextRun><Value /><Style>NoneStyle>TextRun>TextRuns><Style><TextAlign>LeftTextAlign>Style>Paragraph>Paragraphs>" +
    186. "<rd:DefaultName>totalall" + _reportItemPatterns.Count.ToString() + i.ToString() + "rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    187. "<PaddingLeft>0ptPaddingLeft><PaddingRight>0ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>0ptPaddingBottom>Style>Textbox>CellContents>TablixCell>\r\n\r\n";
    188. }
    189. }
    190. else
    191. {
    192. if (Convert.ToInt32(totalWidth) > 0) totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"totalname" + _reportItemPatterns.Count.ToString() + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    193. "<Paragraphs><Paragraph><TextRuns><TextRun><Value>" + totalString + "Value><Style><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize><FontWeight>BoldFontWeight>Style>TextRun>TextRuns><Style><TextAlign>RightTextAlign>Style>Paragraph>Paragraphs>" +
    194. "<rd:DefaultName>totalname" + _reportItemPatterns.Count.ToString() + "rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    195. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>3ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox><ColSpan>" + totalWidth + "ColSpan>CellContents>TablixCell>\r\n\r\n";
    196. for (int i = 1; i < Convert.ToInt32(totalWidth); i++)
    197. {
    198. totalCellPattern += "<TablixCell />\r\n\r\n";
    199. }
    200. totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"totalValue" + _reportItemPatterns.Count.ToString() + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    201. "<Paragraphs><Paragraph><TextRuns><TextRun><Value>=Sum(CDec(Fields!" + totalColumn + ".Value))Value><Style><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize><FontWeight>BoldFontWeight>Style>TextRun>TextRuns><Style><TextAlign>RightTextAlign>Style>Paragraph>Paragraphs>" +
    202. "<rd:DefaultName>totalValue" + _reportItemPatterns.Count.ToString() + "rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    203. "<PaddingLeft>0ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>\r\n\r\n";
    204. for (int i = 1; i < (coloumNames.Length - Convert.ToInt32(totalWidth)); i++)
    205. {
    206. totalCellPattern += "<TablixCell><CellContents><Textbox Name=\"total" + _reportItemPatterns.Count.ToString() + i + "\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether>" +
    207. "<Paragraphs><Paragraph><TextRuns><TextRun><Value /><Style>NoneStyle>TextRun>TextRuns><Style><TextAlign>LeftTextAlign>Style>Paragraph>Paragraphs>" +
    208. "<rd:DefaultName>total" + _reportItemPatterns.Count.ToString() + i + " rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>NoneStyle>Border><VerticalAlign>TopVerticalAlign>" +
    209. "<PaddingLeft>0ptPaddingLeft><PaddingRight>0ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>0ptPaddingBottom>Style>Textbox>CellContents>TablixCell>\r\n\r\n";
    210. }
    211. }
    212. totalCellPattern += "TablixCells>TablixRow>";
    213. totalMemberPattern = "<TablixMember><KeepWithGroup>BeforeKeepWithGroup>TablixMember>";
    214. }
    215. //计算表格应该离左边多少距离
    216. var leftPosition = (pageWidth - tableWidth) / 2;
    217. if (leftPosition < leftMargin / 2) leftPosition = leftMargin / 2;
    218. var dataSetName = string.Format("Data{0}", _reportItemPatterns.Count + _reportHeadPatterns.Count + 1);
    219. var reportItemPattern = new ReportItemPattern();
    220. reportItemPattern.Data = DynamicReportExtension.RemoveZeroData(data);
    221. reportItemPattern.DataSetName = dataSetName;
    222. reportItemPattern.DataSetString =
    223. reportItemPattern.DataSetPattern
    224. .Replace("@DataSetName", dataSetName)
    225. .Replace("@Fields", fields.ToString());
    226. reportItemPattern.TablixString =
    227. reportItemPattern.TablixPattern
    228. .Replace("@DataSetName", dataSetName)
    229. .Replace("@TablixColumns", coloums.ToString())
    230. .Replace("@TablixHeader", tablixHearders.ToString())
    231. .Replace("@TablixCells", tablixCells.ToString())
    232. .Replace("@TablixMember", tablixMembers.ToString())
    233. .Replace("@TotalRow", totalCellPattern.ToString())
    234. .Replace("@MergeMember", mergeMemberPattern.ToString())
    235. .Replace("@TotalMember", totalMemberPattern.ToString())
    236. .Replace("@TopPosition", CaculatePlacePostion().ToString())
    237. .Replace("@LeftPostion", leftPosition.ToString());
    238. //读取行数,如果是空行就加到新的
    239. if (dataRows == 0)
    240. {
    241. _reportHeadPatterns.Add(reportItemPattern);
    242. }
    243. else
    244. {
    245. _reportItemPatterns.Add(reportItemPattern);
    246. }
    247. if (totalCellPattern != "")
    248. {
    249. tabelTopPosition = CaculatePlacePostion() + hearderHeight - 0.3F;
    250. }
    251. else
    252. {
    253. tabelTopPosition = CaculatePlacePostion() + hearderHeight - 0.5F;
    254. }
    255. }
    256. protected float CaculatePlacePostion()
    257. {
    258. //每个数据表的高度
    259. float itemCount = _reportItemPatterns.Count * 2f;
    260. // 每个空表头的高度
    261. float emptyItemCount = _reportHeadPatterns.Count * 0.5f;
    262. return itemCount + emptyItemCount;
    263. }
    264. private void GetHearderMerge(StringBuilder tablixHearders, float currentNamePrefix)
    265. {
    266. string topBorder = "";
    267. if (hearderTop.Rows.Count > 0)
    268. {
    269. topBorder = "<TopBorder><Style>NoneStyle>TopBorder>";
    270. for (int i = 0; i < hearderTop.Rows.Count; i++)
    271. {
    272. if ((Int32)hearderTop.Rows[i]["CellNumber"] == 1)
    273. {
    274. tablixHearders.AppendFormat("<TablixCell><CellContents>" +
    275. "<Textbox Name=\"TextboxTop{0}{1}\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether><Paragraphs><Paragraph>" +
    276. "<TextRuns><TextRun><Value /><Style><FontWeight>BoldFontWeight><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    277. "<rd:DefaultName>TextboxTop{0}{1}rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border><BottomBorder><Style>NoneStyle>BottomBorder><VerticalAlign>MiddleVerticalAlign>" +
    278. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>",
    279. i, currentNamePrefix);
    280. }
    281. else
    282. {
    283. string borderString = "";
    284. if (hearderTop.Rows[i]["CellValue"].ToString().Trim() == "") borderString = "<BottomBorder><Style>NoneStyle>BottomBorder>";
    285. tablixHearders.AppendFormat("<TablixCell><CellContents>" +
    286. "<Textbox Name=\"TextboxTop{0}{1}\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether><Paragraphs><Paragraph>" +
    287. "<TextRuns><TextRun><Value>" + hearderTop.Rows[i]["CellValue"].ToString() + "Value><Style><FontWeight>BoldFontWeight><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    288. "<rd:DefaultName>TextboxTop{0}{1}rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border>" + borderString + "<VerticalAlign>MiddleVerticalAlign>" +
    289. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox><ColSpan>" + hearderTop.Rows[i]["CellNumber"].ToString() + "ColSpan>CellContents>TablixCell>",
    290. i, currentNamePrefix);
    291. for (int n = 1; n < Convert.ToInt32(hearderTop.Rows[i]["CellNumber"]); n++)
    292. {
    293. tablixHearders.AppendFormat("<TablixCell />");
    294. }
    295. }
    296. }
    297. tablixHearders.AppendFormat("TablixCells>" +
    298. " TablixRow>" +
    299. " <TablixRow>" +
    300. " <Height>0.5cmHeight>" +
    301. " <TablixCells>");
    302. }
    303. if (hearderMerge.Rows.Count > 0)
    304. {
    305. for (int i = 0; i < hearderMerge.Rows.Count; i++)
    306. {
    307. if ((Int32)hearderMerge.Rows[i]["CellNumber"] == 1)
    308. {
    309. tablixHearders.AppendFormat("<TablixCell><CellContents>" +
    310. "<Textbox Name=\"TextboxMerge{0}{1}\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether><Paragraphs><Paragraph>" +
    311. "<TextRuns><TextRun><Value /><Style><FontWeight>BoldFontWeight><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    312. "<rd:DefaultName>TextboxMerge{0}{1}rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border>" + topBorder + "<BottomBorder><Style>NoneStyle>BottomBorder><VerticalAlign>MiddleVerticalAlign>" +
    313. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox>CellContents>TablixCell>",
    314. i, currentNamePrefix);
    315. }
    316. else
    317. {
    318. tablixHearders.AppendFormat("<TablixCell><CellContents>" +
    319. "<Textbox Name=\"TextboxMerge{0}{1}\"><CanGrow>trueCanGrow><KeepTogether>trueKeepTogether><Paragraphs><Paragraph>" +
    320. "<TextRuns><TextRun><Value>" + hearderMerge.Rows[i]["CellValue"].ToString() + "Value><Style><FontWeight>BoldFontWeight><FontFamily>" + fontString + "FontFamily><FontSize>" + fontSize + "ptFontSize>Style>TextRun>TextRuns><Style><TextAlign>CenterTextAlign>Style>Paragraph>Paragraphs>" +
    321. "<rd:DefaultName>TextboxMerge{0}{1}rd:DefaultName><Style><Border><Color>DarkGrayColor><Style>SolidStyle>Border>" + topBorder + "<VerticalAlign>MiddleVerticalAlign>" +
    322. "<PaddingLeft>2ptPaddingLeft><PaddingRight>2ptPaddingRight><PaddingTop>2ptPaddingTop><PaddingBottom>1ptPaddingBottom>Style>Textbox><ColSpan>" + hearderMerge.Rows[i]["CellNumber"].ToString() + "ColSpan>CellContents>TablixCell>",
    323. i, currentNamePrefix);
    324. for (int n = 1; n < Convert.ToInt32(hearderMerge.Rows[i]["CellNumber"]); n++)
    325. {
    326. tablixHearders.AppendFormat("<TablixCell />");
    327. }
    328. }
    329. }
    330. tablixHearders.AppendFormat("TablixCells>" +
    331. " TablixRow>" +
    332. " <TablixRow>" +
    333. " <Height>0.5cmHeight>" +
    334. " <TablixCells>");
    335. }
    336. }

    动态RDLC报表(一)

    动态RDLC报表(二)

    动态RDLC报表(三)

    动态RDLC报表(四)

    动态RDLC报表(五)

    动态RDLC报表(六)

    动态RDLC报表(七)

    动态RDLC报表完整实例下载

  • 相关阅读:
    QGIS编译(跨平台编译)之五十一:Qt Creator环境下qgis_native库的pro文件
    南瓜科学好奇盒子上新 打造新时代玩具总动员
    NETCONF、RESTCONF和YANG
    昭通市鲁甸县卯家湾安置区:凝心聚力 共谱民族团结进步新篇章
    python日志管理
    Apache Kyuubi & Celeborn,助力 Spark 拥抱云原生
    好强型性格分析,如何改变好强型性格?
    第4套.py
    数据在内存中的存储(1)
    文献学习-14-一种用于高精度微创手术的纤维机器人
  • 原文地址:https://blog.csdn.net/xgh815/article/details/126245597