在运行时设计报告
我正在开发一个 Windows 窗体应用程序,它有几个包含使用 vb.net 的 datagridviews 的窗口。客户最近提出了能够打印每个表的数据的愿望。
几个月前,我使用 Crystal Reports 成功设计并实现了我的第一份报告,我的第一反应是使用 Crystal Reports 来完成此任务。但是,因为我已经确切地知道我想要在第一份报告中呈现哪些列和数据,所以我可以在设计报告时考虑到这一点,所以这没有问题。
现在,挑战是我事先不知道要在报告中打印的确切列数,所以我担心我必须以编程方式设计报告,所以我的问题是;
是否有任何方法可以以编程方式设计报告?例如,我可以仅使用代码告诉水晶报表在详细信息部分中放置一个“表对象”,然后放置一个名为 X 的列和另一个名为 Y 的列吗?如果可能的话,有人可以向我指出一些关于如何执行此操作或类似操作的示例代码吗?
如果 1 在水晶报表中不可能,有人可以向我指出一些其他可以实现 1 的报表软件吗?如果可能的话,如何实现?
我是否合理地处理问题,或者是否有更好、更简单的方法可以实现客户的愿望?
顺便说一句,我已经提供了将表格导出到 Excel 的可能性,客户可以根据需要打印它们,但他们似乎更喜欢带有徽标和其他内容的更精美的报告,就像在水晶报告中可以实现的那样。
对于实现此功能的任何帮助,我将非常感激。
i am developing a windows forms application which has several windows containing datagridviews using vb.net. The client just recently came up with the desire to be able to print the data of each of these tables.
Having succesfully designed and implemented my first report using Crystal reports a few months ago, my first instinct was to do this using crystal reports. However, because I already knew exactly which columns and data I wanted to present in my first report, I could design the report taking this into account, so this was no problem.
Now, the challenge is that I do not know the exact number of columns to be printed in the report before hand, so I'm afraid I'd have to design the report programmatically, so my questions are;
Is there any means of desgining a report programmatically? For example, can I, using only code, tell crystal reports to put a "table object" in the details section, then put a column named X, and another named Y? If possible, can someone point me to some sample code on how to do this or something similar?
If 1 is not possible in crystal reports, can someone point me to some other reporting software in which I could achieve 1, and if possible, how?
Am I approaching the problem reasonably or is there a much better and easier way in which I could achieve the clients desires?
By the way, I already provided the possibility to export the tables to excel, from which the client could print them as they wish, but it would appear they prefer fancier looking reports with logos and stuff as one could achieve in crystal reports.
I'll be extremely grateful with any help in implementing this functionality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你有两种方法可以做到这一点,一种是困难的,另一种是简单的。首先让我们把最困难的部分解决掉。 CR 拥有功能齐全的库,可让您几乎从头开始创建报告。它称为 RAS 库。但这非常复杂,对于刚接触 Crystal 的人来说并不是最好的选择。
下一个解决方案(也是最简单的)是创建一个包含您可能需要的所有可能字段的报告,然后使用 ReportObject 模型动态隐藏您不需要显示的字段。因此,如果您的报告中有 5 到 10 列,请在报告中创建所有 10 列。然后在您的应用程序中,如果您不需要第 10 列,请将其隐藏。像这样的东西:
You have two ways of doing this, one is hard the other easy. First let's get the hard one out of the way. CR has a fully functional library which lets you create reports almost from scratch. It's called the RAS library. But it's very complex and not the best thing for someone new to Crystal to undertake.
The next solution, and the easiest, is to create a report that has all the possible fields you could ever need and then use the ReportObject model to dynamically hide the fields you don't need to show. Thus, if you could have between 5 to 10 columns on your report, create all ten of them in the report. Then in your app, if you don't need the 10th column, hide it. Something like this:
如果您需要真正动态且可能更简单,请查看 list &标签。
您需要做的事情的示例看起来有些简单:
更多详细信息在这里.. .
您至少需要“专业版”-版本才能使用此功能。
我用这个成熟的软件做了一些不错的程序。
if you need it really dynamical and perhaps easier, take a look into list & label.
the sample of what you need to do looks somewhat easy:
More Details here...
You need at least the "Professional"-Edition to use this feature.
i've done some nice programs with this mature software.
这很容易做到,我只是想告诉您执行该操作的新方法,流程如下:
浏览器具有从文件打印预览打印页面内容的功能
这是动态报告,只需从 SQL 查询中获取所需的数据
This is very easy to do I just want to tell you for new methods to do that flow this steps:
The browser have functionality to print the page content from file-print preview
this is dynamic report just get your data you want from SQL query