找回密码
 立即注册

QQ登录

只需一步,快速开始

877121273

中级会员

116

主题

361

帖子

901

积分

中级会员

积分
901

微信认证勋章

877121273
中级会员   /  发表于:2016-2-16 09:16  /   查看:3808  /  回复:8
自定义报表能增加一行合计吗?

8 个回复

倒序浏览
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2016-2-16 11:51:00
沙发
可以实现:
如果您使用的是Table控件,为Table 可在table footer 中实现合计功能:注意下面几行代码:
1. 初始化值时, 添加合计运算表达式:String[] textBoxValues = new String[] { "helloTitle", "Year Released", "MPAA", "=Fields!Title.Value", "=Fields!YearReleased.Value", "=Fields!MPAA.Value", "=Sum(Fields!Title.Value+Fields!YearReleased.Value)", "=Sum(Fields!Title.Value+Fields!YearReleased.Value)", "=Sum(Fields!Title.Value+Fields!YearReleased.Value)" };
2. 将对应Row 设为Table.Footer:  table.Footer.TableRows.Add(tableRows[2]);

  1. Table table = new Table();
  2.             table.Name = "Table1";
  3.             //Creating the rows,columns as well as TableCells for the table as well as TextBoxes to be placed within the Table Cells
  4.             TextBox[] tableTextBoxes = new TextBox[9];
  5.             TableCell[] tableCells = new TableCell[9];
  6.             TableRow[] tableRows = new TableRow[3];
  7.             TableColumn[] tableColumns = new TableColumn[3];
  8.             String[] textBoxValues = new String[] { "helloTitle", "Year Released", "MPAA", "=Fields!Title.Value", "=Fields!YearReleased.Value", "=Fields!MPAA.Value", "=Sum(Fields!Title.Value+Fields!YearReleased.Value)", "=Sum(Fields!Title.Value+Fields!YearReleased.Value)", "=Sum(Fields!Title.Value+Fields!YearReleased.Value)" };
  9.             String[] columnsWidth = new String[] { "9cm", "4.6cm", "5.3cm" };
  10.             String[] rowsHeight = new String[] { "1.5cm", "1.5cm","1.5cm" };
  11.             //Setting properties for the Textboxes to be placed in the TableCells
  12.             for (int i = 0; i < tableTextBoxes.Length; i++)
  13.             {
  14.                 tableTextBoxes.SetValue(new TextBox(), i);
  15.                 tableTextBoxes[i].Name = "textBox" + (i + 1);
  16.                 tableTextBoxes[i].Value = ExpressionInfo.FromString(textBoxValues[i]);
  17.                 tableTextBoxes[i].Style.PaddingBottom = tableTextBoxes[i].Style.PaddingLeft = tableTextBoxes[i].Style.PaddingRight = tableTextBoxes[i].Style.PaddingTop = ExpressionInfo.FromString("2pt");
  18.                 tableTextBoxes[i].Style.TextAlign = ExpressionInfo.FromString("Left");
  19.                 tableCells.SetValue(new TableCell(), i);
  20.                 tableCells[i].ReportItems.Add(tableTextBoxes[i]);//Adding the TextBoxes to the TableCells
  21.                 if (i < rowsHeight.Length)
  22.                 {
  23.                     tableRows.SetValue(new TableRow(), i);
  24.                     tableRows[i].Height = "1.25cm";
  25.                     table.Height += "1.25cm";
  26.                 }
  27.                 if (i < columnsWidth.Length)
  28.                 {
  29.                     tableColumns.SetValue(new TableColumn(), i);
  30.                     tableColumns[i].Width = columnsWidth[i];
  31.                     table.Width += columnsWidth[i];
  32.                     table.TableColumns.Add(tableColumns[i]);
  33.                     tableCells[i].ReportItems[0].Style.BackgroundColor = ExpressionInfo.FromString("LightBlue");
  34.                     tableRows[0].TableCells.Add(tableCells[i]);
  35.                 }
  36.                  if(i>2 &amp;&amp; i<6)
  37.                 {
  38.                     tableCells[i].ReportItems[0].Style.BackgroundColor = ExpressionInfo.FromString("=Choose((RowNumber("Table1") +1) mod 2, "PaleGreen",)");
  39.                     tableRows[1].TableCells.Add(tableCells[i]);
  40.                 }

  41.                  if (i > 5 &amp;&amp; i < 9)
  42.                  {
  43.                      tableRows[2].TableCells.Add(tableCells[i]);

  44.                  }
  45.             }
  46.             table.Header.TableRows.Add(tableRows[0]);
  47.             table.Details.TableRows.Add(tableRows[1]);
  48.             table.Footer.TableRows.Add(tableRows[2]);
  49.             table.Top = "1cm";
  50.             table.Left = "0.635cm";
  51.             report.Report.Body.ReportItems.Add(logo);
  52.             report.Report.Body.ReportItems.Add(table);
复制代码
回复 使用道具 举报
877121273
中级会员   /  发表于:2016-2-16 12:04:00
板凳

可以在下面代码的基础上添加吗?

可以在下面代码的基础上添加吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
877121273
中级会员   /  发表于:2016-2-16 12:10:00
地板
可以实现行统计和列统计吗
回复 使用道具 举报
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2016-2-16 12:17:00
5#
您好,您的账户已经升级为金牌用户,您可以在金牌服务区发帖了。
在区域报表中同样添加,实现思路是一样的。
回复 使用道具 举报
877121273
中级会员   /  发表于:2016-2-16 16:41:00
6#
我使用的不是table控件的,是多个Label拼起来的报表
回复 使用道具 举报
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2016-2-16 16:45:00
7#
您能上传您的示例程序吗?我在这边根据您实际的报表实现,给出解决方法。
回复 使用道具 举报
877121273
中级会员   /  发表于:2016-2-16 17:34:00
8#

附件

附件

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2016-2-16 17:50:00
9#
附件中只有一个resk资源文件,是不是没上传完?
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部