如何为打印报告编写简单的设计器

发布于 2024-11-04 04:17:06 字数 595 浏览 0 评论 0原文

我目前有几份从表单应用程序打印的报告。 然而,仅使用内置的 .NET 打印方法构建打印报告非常繁琐。即使只是在几页上打印一个简单的表格并进行一些格式化,也是一个几个小时的任务(如果它看起来不错的话)。

我需要的是一个所见即所得的布局设计器,所以我想写一个。 它不应该适合最终用户,但对于我作为开发人员来说,它只是要创建报告的布局,具有各种排列/字体/图像/格式等,而不必通过试验来做到这一点&代码错误(并重新启动应用程序无数次)。

所以我的具体问题是:

  1. 我将使用什么作为编辑和显示报告的画布?我可以像在打印文档上一样绘制图像控件/位图吗?有更好的方法吗?

  2. 在表格上绘图与在打印页面上绘图是否可比?打印机与屏幕的分辨率有何差异?

  3. 如何获得真正的所见即所得?我应该获取打印机设置并创建具有相同分辨率的画布吗?还有其他需要考虑的吗?

我知道周围有报表设计者,但我认为有时了解您所使用的基本工作原理是很好的,并且实现它们对我来说是做到这一点的最佳方法。

我知道这不是一个答案总是 B 的特定问题 A,但如果是这样的话,我会很快在 Google 中找到答案。

提前致谢!

I'm currently having a couple of reports which I print from my Forms applications.
However building printed reports only with the built-in .NET printing methods is very tedious. Even just printing a simple table on a couple of pages with a little bit of formatting is a task for a couple of hours (if it should look nice).

What I need is a WYSIWYG-Designer for the layouts, so I'd like to write one.
It shouldn't be for End-Users, but for me as a developer, it's just about to create the layout what the report will look like with various arrangements/fonts/images/formats and so on and not have to do that by trial & error in code (and restart the app a zillion times).

So my specific questions:

  1. What would I use as a canvas for editing and display of the report? An image-control/bitmap which I draw upon like on the printed document? Is there a better way?

  2. Is drawing on a form comparable to drawing on a printed page? What about differences in resolution printer vs. screen?

  3. How to get real WYSIWYG? Should I get the printer settings and create my canvas with the same resolution? Is there something else to consider?

I know that there are report designers around but I think it's sometimes good to understand the basic working principles of what you use and implementing them is for me the best way to do that.

I'm aware that this is not a specific question A to which the answer is always B, but if it were that way I would find an answer in Google pretty quickly.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

悲凉≈ 2024-11-11 04:17:06

关于设计所见即所得编辑器,我不能说太多,但我已经编写了一些自定义的内部报告引擎供我们的开发团队使用。

我创建报告的主要方式有两种。第一个是使用 PDFsharp(MIT 许可)手动布局页面,这不适合胆小的人心。

第二种是使用 Winnovative 的 HTML 到 PDF 库(不是免费的,但免版税),它使用当前的安装版本的 IE 进行布局并吐出 PDF。看起来他们最近发布了一个名为 EVO PDF 的新版本,我以前从未使用过。

* HTML 到 PDF 解决方案,它支持 JavaScript,因此您可以从 JavaScript 库添加图表,例如 flotjqplot

*我不隶属于 Winnovative。

I can't say much about designing a WYSIWYG editor, but I have written a few custom in-house reporting engines for use by our development team.

There's two main ways I've created reports. The first is using PDFsharp (MIT-licensed) to manually layout pages which isn't for the faint-of-heart.

The second is using Winnovative's HTML to PDF library (not free, but royalty-free) which uses the current installed version of IE to do the layout and spit out a PDF. It looks like they've recently released a new version called EVO PDF which I have never used before.*

For the HTML to PDF solution, it supports JavaScript so you can add in charts from JavaScript libraries like flot or jqplot.

*I'm not affiliated with Winnovative.

情丝乱 2024-11-11 04:17:06

您可能想节省时间并使用 Visual Studio HTML 设计器作为所见即所得编辑器。

我目前正在做的是使用 ASP.NET MVC 3 作为简单的报告引擎。当使用 Visual Studio 作为报表设计器时,您可以使用 MVC 模式真正分离报表数据源(模型)和呈现(视图)。

从您的应用程序中,您可以使用报告可选参数轻松调用您的操作。例如:

http://localhost/Report/Customer/Orders/1

您只需得到返回的从 WebClient 的 DownloadString 方法获取字符串,然后您就可以生成报告了。

使用 HTML 有一些缺点,主要是很难知道页面何时会中断,但是通过在视图中使用代码,您可以计算重复项目的数量并添加 CSS 中断页面并在页面上重新启动表格的标题。下一页。

您可以实现从图形到表格的任何内容,甚至可以生成到其他报告的链接。

HTH。

You might want to save time and use Visual Studio HTML designer as your WYSIWYG editor.

What I'm currently doing is using ASP.NET MVC 3 as a simple reporting engine. You can use the MVC pattern to really separate your reporting data source (Model) and the rendering (View) while using Visual Studio as your report designer.

From your application you can easily call your actions with the report optional parameters. For example:

http://localhost/Report/Customer/Orders/1

You simply get the returning string from a WebClient's DownloadString method and you have your report generated.

There is some down side using HTML, mainly the difficulties to know when a page would break, but by using code in your View you can calculate the amount of repeating items and add a CSS break-page and re-starting your table's header on the next page.

You can achieve anything from graphics, to table, you can even generate link to other reports.

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文