如何使用 C# 从数据库打印(在打印机上)表格

发布于 2024-12-25 16:44:16 字数 171 浏览 4 评论 0原文

我从事一些从 vb6 迁移到 web (asp.net) 的项目。我需要打印某种报告 - 数据库中的表格以及带有日期和时间的简单标题的数量。在 vb 中它是使用 vsPrinter 对象实现的。 C#中是否有任何类的功能与vb6中的该类类似?如果.net中没有这样的东西,那么最简单的方法是什么?

感谢您的帮助!

I work on some project that is migrating from vb6 to web (asp.net). I need to print some kind of report - A table from database and number of simple headers with date and time. In vb it was implemented using vsPrinter object. Is there any Class in C# that is similar to this Class in vb6 in its functionality? If there in no such thing in .net, what is the easiest way to do this?

Thanx for assistance!

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

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

发布评论

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

评论(2

冷夜 2025-01-01 16:44:16

请记住,您正在转向网络,因此您无法访问硬件打印机控件。您只能访问浏览器为您提供的内容。如果您没有对此做任何花哨的事情,您可以做以下两件事之一。

  1. 由于这是一个 ASP.NET 网页,因此只需创建一个新的浏览器或弹出窗口并将报告呈现为 html。用户可以从浏览器打印对话框中选择打印,或者您可以使用一些生成的 JavaScript 启动它。
  2. 如果您需要更正式的报表布局,请使用 Microsoft Report 和 Report Viewer 控件。这些可以从您的工具箱中的“报告”类别下获得。

Remember you are moving to the web so you don't have access to the hardware printer controls. You only have access to what the browser gives you. If you are not doing anything fancy with this you can do one of two things.

  1. Since this is an ASP.NET webpage, simply create a new browser or popup and render your report as html. The user can them choose print from the browser print dialog or you can launch it with some generated javascript.
  2. Use the Microsoft Report and Report Viewer controls is you need more formal report layout. These are available from your toolbox under the category Reporting.
别闹i 2025-01-01 16:44:16

我认为最简单的方法是使用任何报告工具,最强大的工具之一是 Crystal reports,只需谷歌一下,您就会发现很多有用的教程,例如:

您还可以找到在 Crystal 下,有很多关于它的有用线程Reports 标记,例如:

I think the easiest way would be by using any reporting tool, one of the powerfull tools is Crystal reports, just google it an you will find alot of useful tutorial such as:

You can also find alot of useful threads about it here in SO under Crystal Reports tag, like:

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