如何在报告上显示过滤数据? [英] How do I display filtered data on a report?

查看:67
本文介绍了如何在报告上显示过滤数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我从未使用过Crystal Reports,你可以用它来做很有趣的事情。但是在为单个客户创建报告时我很挣扎。那么,让我解释一下我真正拥有的以及我想要做什么。



首先,我有2个表,一个关于客户数据(包括照片),另一个是关于添加到该客户端的订阅。如果是这样,我如何获取所有参数的客户数据,然后在同一报告上显示有关该客户的订阅数据?



我从未使用过水晶报告所以我只能在列上显示单个数据集。但这不是我想要的。我只想要客户端数据,如(C_ID,名称,城市,地址,电子邮件和照片上的参数,以及System.DateTime.Now()在不同的参数上),然后在我要设置的所有数据下根据为所有参数选择的同一客户端,从表中获取订阅表中的值。我在youtube上看过3/4的教程,但没有一个太明确,导致我理解的比我已经知道的少(固体0)。关于如何解决这个问题的任何想法?





我的2桌:

[表格]



PS:我真的需要一些关于这个问题的好教程,无论是文章还是视频。



我尝试了什么:



关于将文本框传递给参数的所有教程,但它们似乎都不适合我的需要。这些教程都没有根据特定的客户端值获取表值。

Hello,
I've never used Crystal Reports and it's quite interesting what you can do with it. But I'm struggling when creating a report for a single client. So, let me explain what I really have and what I want for this to be possible to make.

Firstly, I have 2 tables, one regarding client data(including a photo) and the other is regarding a subscription added to that client. If so, How can I get the client data to all the parameters and then show the subscription data regarding that client on the same report?

I've never used crystal reports so I only can display single datasets on columns. But that's not what I want. I simply want the client data like (C_ID, Name, City, Address, Email and Photo on the parameters, as well as the System.DateTime.Now() on a different parameter) and then under all that data I would like to set up a table to get the values from the subscription table according to the same client chosen for all the parameters. I've seen 3/4 tutorials on the youtube but none of them was too explicit causing me to understand less than what I knew already(A solid 0). Any idea on how to solve this problem?


My 2 tables:
[Tables]

PS: I really need some good tutorials regarding this problem, either articles or videos.

What I have tried:

Followed all the tutorials regarding passing textbox to parameters but none of them seem to fit my needs. Neither the tutorials related to getting the table values based on a specific client value.

推荐答案

根据您的编写,我假设您几乎没有准备报告的经验。你提到Crystal Reports,但是我建议你看一下好的MS Word能为你做些什么。 MS Word的一个好处是您可以准备模板文档并根据需要对其进行格式化。然后将占位符放入您希望数据显示的位置。



在.NET应用程序中,您可以将数据库中的数据读入.NET数据对象或XML。最后一步是合并数据和模板。请查看这些示例以了解详情。以下是一些代码,以帮助您入门(使用Entity Framework从数据库中读取数据):



From what you've wrote I assume you have little experience with preparing reports. You are mentioning Crystal Reports, but let me suggest to take a look at what the good old MS Word can do for you. One nice thing about MS Word is that you can prepare a template document and format it as needed. Then put placeholders into it where you want your data to appear.

In your .NET application you then read the data from your database into .NET data objects or XML. The last step is to merge the data and the template. Take a look at these examples to learn more. And here is some code, to help you get started (the data is read from the database using Entity Framework):

using Docentric.Documents.Reporting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace clientReport
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new clientsEntities())
            {
                string templateDocument = @"C:\Temp\ClientsTemplate.docx";
                string finalDocument = @"C:\Temp\ClientsReport.docx";

                ClientLst cl = new ClientLst();
                cl.Data = new List<ClientOutput>();

                var q = context.Clients.ToList<Client>();

                foreach (Client c in q)
                {
                    ClientOutput co = new ClientOutput();
                    co.Cid = c.C_ID;
                    co.Name = c.Name;
                    co.Address = c.Address;
                    co.City = c.City;
                    co.Email = c.Email;
                    co.Picture = c.Picture;

                    cl.Data.Add(co);
                }
                
                Console.WriteLine("Count of records read ..." + cl.Data.Count.ToString());

                DocumentGenerator dg = new DocumentGenerator(cl);
                DocumentGenerationResult result = dg.GenerateDocument(templateDocument, finalDocument, SaveOptions.Pdf);

                Console.Write("Press any key to continue ...");
                Console.ReadKey();
            }
        }        
    }
    public class ClientOutput
    {
        public int Cid { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string Email { get; set; }
        public byte[] Picture { get; set; }
    }
    public class ClientLst
    {
        public List<ClientOutput> Data { get; set; }
    }
}



此代码从数据库中读取数据,填充.NET数据对象(ClientOutput和ClientList)并生成最终文档作为普通的MS Word docx文件(其他支持的输出格式是pdf,xps和image)。您可以看到代码非常简单但功能强大。


This code reads the data from the database, fills .NET data objects (ClientOutput and ClientList) and generates the final document as plain MS Word docx file (other supported output formats are pdf, xps and image). You can see that the code is very simple, yet powerful.


这篇关于如何在报告上显示过滤数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆