简体   繁体   English

Visual Studio 2005 中的 Crystal Reports(C# .NET Windows 应用程序)

[英]Crystal Reports in Visual Studio 2005 (C# .NET Windows App)

I need to create reports in a C# .NET Windows app.我需要在 C# .NET Windows 应用程序中创建报告。 I've got an SQL Server 2005 .I want to display two more field to report(not available in data base table. I want to create these field by adding some data from existing field of data base table)我有一个 SQL Server 2005。我想再显示两个要报告的字段(在数据库表中不可用。我想通过从数据库表的现有字段添加一些数据来创建这些字段)

If you look at the .NET API exposed by Crystal Reports, you'll find that you can inject a DataSet into a report - this gives your application full control over the data used by the report, leveraging Crystal Reports as a presentation engine.如果您查看 Crystal Reports 公开的 .NET API,您会发现您可以将 DataSet 注入到报表中 - 这使您的应用程序可以完全控制报表使用的数据,并利用 Crystal Reports 作为表示引擎。

I've used this technique to generate reports over data soures not natively supported by Crystal Reports - it also helps to ensure that all the data comes from the sames source (as the API for changing the connection used within a normal Crystal report is somewhat flakey).我已经使用这种技术在 Crystal Reports 本身不支持的数据源上生成报告——它还有助于确保所有数据来自相同的源(因为用于更改普通 Crystal 报告中使用的连接的 API 有点古怪)。

So, what I'd do in your situation is to load all the required data into a DataSet, add the extra columns, and then pass the dataset into the report.因此,在您的情况下,我要做的是将所有必需的数据加载到 DataSet 中,添加额外的列,然后将数据集传递到报告中。 Only complex bit is that you need to save out the XML schema of the dataset and import it into Crystal Reports so that it is aware of the shape of your data.唯一复杂的一点是您需要保存数据集的 XML 模式并将其导入 Crystal Reports,以便它了解您的数据的形状。

You could use a crystal function also for this.您也可以为此使用水晶功能。 Depending on how complex the calculation is from Column A to B. The more complex the easier it becomes just to do what Bevan says and change the dataset.取决于计算从 A 列到 B 列的复杂程度。越复杂,按照 Bevan 所说的去做并更改数据集就越容易。

If you were more specific i might be able to give you some example code.如果您更具体,我可能会给您一些示例代码。

使用 CR 公式字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM