RDLC报告分组以下

问题描述

我要在报告上设置的对象

public class SurveyTemplateReportModel
{
    public string Topic { get; set; }
    public string Section { get; set; }
    public string QuestionName { get; set; }
    public string Question { get; set; }
    public string Field { get; set; }
}

报告结构

**Topic 1**
**Section 1**

QuestionName 1.0
Question 1.0
Field 1.0

QuestionName 1.1
Question 1.1
Field 1.1

**Section 1.1**

QuestionName 1.1.0
Question 1.1.0
Field 1.1.0

QuestionName 1.1.1
Question 1.1.1
Field 1.1.1

**Section 2.0**

QuestionName 2.0.0
Question 2.0.0
Field 2.0.0

QuestionName 2.0.1
Question 2.0.1
Field 2.0.1

QuestionName 2.0.2
Question 2.0.2
Field 2.0.2

任何人都可以帮助我设置此类报告

解决方法

c#代码如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<SurveyTemplateReportModel> model = new List<SurveyTemplateReportModel>() {
                new SurveyTemplateReportModel() { Topic = "1",Section = "1",QuestionName = "1.0",Question = "1.0",Field = "1.0"},new SurveyTemplateReportModel() { Topic = "1",QuestionName = "1.1",Question = "1.1",Field = "1.1"},Section = "1.1",QuestionName = "1.1.0",Question = "1.1.0",Field = "1.1.0"},QuestionName = "1.1.1",Question = "1.1.1",Field = "1.1.1"},Section = "2",QuestionName = "2.0.0",Question = "2.0.0",Field = "2.0.0"},QuestionName = "2.0.1",Question = "2.0.1",Field = "2.0.1"},QuestionName = "2.0.2",Question = "2.0.2",Field = "2.0.2"}
            };

            foreach (var topic in model.GroupBy(x => x.Topic))
            {
               Console.WriteLine("**Topic {0}**",topic.Key);
                foreach (var section in topic.GroupBy(x => x.Section))
                {
                    Console.WriteLine("{0}**Section {1}**",new string(' ',5),section.Key);
                    foreach (SurveyTemplateReportModel survey in section)
                    {
                        Console.WriteLine("{0}QuestionName = {1},Question = {2},Field = {3}",10),survey.QuestionName,survey.Question,survey.Field);
                    }
                }
            }
            Console.ReadLine();
        }
    }
    public class SurveyTemplateReportModel
    {
        public string Topic { get; set; }
        public string Section { get; set; }
        public string QuestionName { get; set; }
        public string Question { get; set; }
        public string Field { get; set; }
    }
}

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...