I want to know I can dynamically modify an existing Crystal Report (using C# and Crystal Reports 2008) so that it can report on fundamentally different data (from the same database) using the same layout. The reason is that we are building an application that allows the user to specify:
我想知道我可以动态修改现有的Crystal Report(使用C#和Crystal Reports 2008),以便它可以使用相同的布局报告基本不同的数据(来自同一数据库)。原因是我们正在构建一个允许用户指定的应用程序:
- A filter so that only the data they are interested in is displayed (i.e., whereclause).
- [e.g., Only display buildings in NYC]
[例如,仅显示纽约市的建筑物]
- Specify what tables are displayed
- [e.g., Show buildings and floors but not rooms]
[例如,显示建筑物和地板,但不显示房间]
- Specify what fields are displayed
- [e.g., Show building id, number, name, address and floor number]
[例如,显示建筑物ID,编号,名称,地址和楼层编号]
- Change how a section is grouped
- [e.g., Group by building use, build year, etc]
[例如,通过建筑使用,建造年份等]
- Change the the fields used in a chart
- [e.g., Area by Building Use, Occupancy by Building Use, Area by Building Id]
[例如,建筑物使用面积,建筑物使用占用面积,建筑物ID面积]
过滤器以便仅显示他们感兴趣的数据(即,在何处使用)。 [例如,仅显示纽约市的建筑物]
指定显示哪些表格[例如,显示建筑物和楼层但不显示房间]
指定显示的字段[例如,显示建筑物ID,编号,名称,地址和楼层编号]
更改部分的分组方式[例如,按建筑使用,构建年份等分组]
更改图表中使用的字段[例如,按建筑物使用的面积,按建筑物使用的占用率,按建筑物ID的面积]
Because of the flexibility of the UI there are many different kinds of "questions" the user can try to report on and I do not want to create a report for every possible combination. For an example of what I am trying to accomplish see the image below. The report on the left depicts buildings grouped by area. The report on the right depicts buildings grouped by site.
由于UI的灵活性,用户可以尝试报告许多不同类型的“问题”,我不想为每种可能的组合创建报告。有关我想要完成的示例,请参见下图。左侧的报告描述了按地区分组的建筑物。右侧的报告描述了按站点分组的建筑物。
Report Comparison http://img119.imageshack.us/img119/9052/performancereportcomparbt7.png
报告比较http://img119.imageshack.us/img119/9052/performancereportcomparbt7.png
EDIT:
I will attempt to be using report parameters to modify the report as suggested by Philippe Grondier. I have had success in doing this by suppressing groups. When a group is suppressed the groups slide up to fill the blank area so that everything lines up without blank space. However, the same behavior is not true of individual text objects. When a text object is suppressed the output for that field is an empty space. What I would like to do is suppress a text object such that the entire line is suppressed which would result in all the entries below it "bumping" up by one line. How can I achieve this?
我将尝试使用报告参数来修改Philippe Grondier建议的报告。通过压制团体,我成功地做到了这一点。当一个组被抑制时,这些组会向上滑动以填充空白区域,以便所有内容都排成一行而没有空格。但是,单个文本对象的行为不同。抑制文本对象时,该字段的输出为空格。我想要做的是抑制一个文本对象,使整个行被抑制,这将导致它下面的所有条目“撞”一行。我怎样才能做到这一点?
1 个解决方案
#1
Depending on the kind of update (and objects concerned by the update), you can use either the free craxdrt.dll (Designer Runtime Library.) or the not free craxddrt.dll (Designer Design and Runtime Library). I forgot the details but you will surely find them on the net.
根据更新的类型(以及更新所关注的对象),您可以使用免费的craxdrt.dll(Designer Runtime Library。)或非免费的craxddrt.dll(Designer Design和Runtime Library)。我忘记了细节,但你肯定会在网上找到它们。
Your questions:
- Filter: it is possible to update the SQLQueryString of the report object at runtime or to update predeclared parameters so that they will be added to the 'Where' clause. I think adding parameters is limited to the craxddrt dll but updating existing ones can be done with the craxdrt dll. You can use the CR interface to update these parameters, or do it through code: one idea would be to update these values in your client interface (from the active form for example) and update them programmatically. Please check here for an example.
- Hidding tables: I don't think that 'hidding tables' makes any sense, as you will need your tables to have all your relations available to calculate your summary values. Thus you can propose to your users the possibility to view/hide details or to view/hide your different grouping levels. This can easily be done with the free craxdrt library and the 'areas' collection/'suppress' method of the report object.
- Once again, playing with the different areas of the report seem to be the best solution here
- I advise you not to think about it! Changing data order can lead to unpredictable results, specially when you calculate intermediate summaries at the group level. Depending on your requests, you could stick to proposal (2), by displaying of not a specific group on the report, or, for simple forms (1 group only), programmatically update at runtime a parameter that will be used in the group definition formula.
- Back to proposal (2): build a complete report will all expected data to be displayed, then hide/show the different sections of the report.
过滤:可以在运行时更新报表对象的SQLQueryString,或者更新预先声明的参数,以便将它们添加到“Where”子句中。我认为添加参数仅限于craxddrt dll,但更新现有参数可以使用craxdrt dll完成。您可以使用CR接口更新这些参数,或通过代码执行:一个想法是在客户端界面中更新这些值(例如,从活动表单)并以编程方式更新它们。请点击此处查看示例。
Hidding表:我认为'隐藏表'没有任何意义,因为您需要使用表来提供所有关系来计算汇总值。因此,您可以向用户建议查看/隐藏详细信息或查看/隐藏不同分组级别的可能性。这可以通过免费的craxdrt库和报表对象的“区域”集合/“抑制”方法轻松完成。
再一次,使用报告的不同区域似乎是最好的解决方案
我建议你不要考虑它!更改数据顺序可能会导致不可预测的结果,尤其是在组级别计算中间摘要时。根据您的请求,您可以通过在报表上显示不是特定组来坚持提议(2),或者对于简单表单(仅限1组),可以在运行时以编程方式更新将在组定义中使用的参数式。
回到提案(2):构建一个完整的报告将显示所有预期的数据,然后隐藏/显示报告的不同部分。
There is another code example available here, showing you how to change the report connection to a different database/different tables at runtime.
这里有另一个代码示例,向您展示如何在运行时将报表连接更改为不同的数据库/不同的表。
#1
Depending on the kind of update (and objects concerned by the update), you can use either the free craxdrt.dll (Designer Runtime Library.) or the not free craxddrt.dll (Designer Design and Runtime Library). I forgot the details but you will surely find them on the net.
根据更新的类型(以及更新所关注的对象),您可以使用免费的craxdrt.dll(Designer Runtime Library。)或非免费的craxddrt.dll(Designer Design和Runtime Library)。我忘记了细节,但你肯定会在网上找到它们。
Your questions:
- Filter: it is possible to update the SQLQueryString of the report object at runtime or to update predeclared parameters so that they will be added to the 'Where' clause. I think adding parameters is limited to the craxddrt dll but updating existing ones can be done with the craxdrt dll. You can use the CR interface to update these parameters, or do it through code: one idea would be to update these values in your client interface (from the active form for example) and update them programmatically. Please check here for an example.
- Hidding tables: I don't think that 'hidding tables' makes any sense, as you will need your tables to have all your relations available to calculate your summary values. Thus you can propose to your users the possibility to view/hide details or to view/hide your different grouping levels. This can easily be done with the free craxdrt library and the 'areas' collection/'suppress' method of the report object.
- Once again, playing with the different areas of the report seem to be the best solution here
- I advise you not to think about it! Changing data order can lead to unpredictable results, specially when you calculate intermediate summaries at the group level. Depending on your requests, you could stick to proposal (2), by displaying of not a specific group on the report, or, for simple forms (1 group only), programmatically update at runtime a parameter that will be used in the group definition formula.
- Back to proposal (2): build a complete report will all expected data to be displayed, then hide/show the different sections of the report.
过滤:可以在运行时更新报表对象的SQLQueryString,或者更新预先声明的参数,以便将它们添加到“Where”子句中。我认为添加参数仅限于craxddrt dll,但更新现有参数可以使用craxdrt dll完成。您可以使用CR接口更新这些参数,或通过代码执行:一个想法是在客户端界面中更新这些值(例如,从活动表单)并以编程方式更新它们。请点击此处查看示例。
Hidding表:我认为'隐藏表'没有任何意义,因为您需要使用表来提供所有关系来计算汇总值。因此,您可以向用户建议查看/隐藏详细信息或查看/隐藏不同分组级别的可能性。这可以通过免费的craxdrt库和报表对象的“区域”集合/“抑制”方法轻松完成。
再一次,使用报告的不同区域似乎是最好的解决方案
我建议你不要考虑它!更改数据顺序可能会导致不可预测的结果,尤其是在组级别计算中间摘要时。根据您的请求,您可以通过在报表上显示不是特定组来坚持提议(2),或者对于简单表单(仅限1组),可以在运行时以编程方式更新将在组定义中使用的参数式。
回到提案(2):构建一个完整的报告将显示所有预期的数据,然后隐藏/显示报告的不同部分。
There is another code example available here, showing you how to change the report connection to a different database/different tables at runtime.
这里有另一个代码示例,向您展示如何在运行时将报表连接更改为不同的数据库/不同的表。