在报表查看器控件中以编程方式设置边距
在我们的应用程序中,我们有一些需要非常特定边距的报告,这些边距取决于用户拥有的打印机。它用于打印到预先格式化的纸张上,并填充空白,并且根据打印机的不同,打印会出现一些边距偏差。更糟糕的是,我们实际上并不控制使用什么打印机,因为它不是内部应用程序。
我能想到的唯一解决方案是让用户以某种方式配置边距。我以为我可以动态地更改报告边距,就像我对数据源和实际报告所做的那样(我有一个控件用于显示应用程序中的每个报告,它工作正常),但我似乎找不到那个该死的属性这样做。报表查看器上有一个边距属性,但它用于表单显示,因此不会剪切它。
有谁知道怎么办。我想做的是在用户加载报告之前定义边距,即当他单击报告按钮时,我加载报告,设置边距(反之亦然是必要的)然后显示它。
在有人提到它之前,我知道用户可以在加载报表后更改页面设置以满足他的需要,但这有两个缺点。第一个是它不是每次都保存,我需要它是“可保存的”并且由用户保存。第二个问题是,当区域设置未设置为预期的值时,报表查看器似乎存在一些错误,并且我们无法强制用户更改其设置以适应某个应用程序。
编辑:忘了提及,这有什么用处。我的报道都是本地报道。
In onw of our application, we have some reports that need very specific margins that are dependant of the printer the user have. It is used to print into preformatted paper with blanks to fill and depending of the printer, the printing is off by some margins. To make things worse, we don't actually control what printer is used because it is not an internal application.
The only solution I could think of is to let the user configure the margins somehow. I thought I could just dynamically change the report margins like I did with datasources and actual report (I have one control that is used to display every reports from my application and it works alright), but I can't seem to find that damn property to do so. There is a margin property on the report viewer but it's for the form display so it doesn't cut it.
Does anyone knows how to. What I was thinking to do is to define the margins before the user loads the report, i.e. when he clicks on the report button, I load the report, set the margins (or vice-versa is necessary) and then display it.
Before someone mention it, I know the user can, once the report is loaded, change the page setup to fit his needs, but this has two drawbacks. First one is that it is not saved each time and I need it to be 'saveable' and by users. The second one is that Report viewer seems to have some bugs when the regional setting aren't set to what it's expecting and we can't force the users to changes their setting to accommodate one application.
Edit: Forgot to mention, it this is of any uses. My reports are all local reports.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你不能直接这样做。尝试使用报表参数控制报表中的边距。
You can't do this directly. Try controlling your margins in the report with report parameters.
嗯,我刚刚遇到了类似的问题;需要一份具有 0 英寸边距的报告,否则该死的东西会从 2 页变成 6 页,并且它垂直分割数据,因此页面没有任何意义。我必须在“打印设置”中手动设置才能打印,但是这份报告的最终目标是以 PDF 形式通过电子邮件发送给客户,你猜怎么着,当我手动设置页边距并导出时,它仍然分成 6 页并被炸毁,因此我冒着一切风险,尽了最后的努力来修复。这该死的东西 - 我用写字板打开了.rdlc,奇迹中的奇迹,发现了1in,等等。我将所有这些buggers设置为0in,保存,运行我的.net代码(2008),打开打印设置,然后哈利路亚,这是我的 0in 设置。现在进行最高测试 - 我将其导出为 PDF,转到文件,真是太棒了!有两个清晰干净的布局完美的页面,一切都很仁慈。我平静下来,让米迪克罗安流过我的身体,享受着一个罕见的时刻,这是一些人很少意识到的——一个简单的修复。
Well, I just had this similar problem; needed a report to have 0" margins, otherwise the blasted thing went from 2 pages to 6, and it split the data vertically, so the pages made no sense. I was having to set it manually in the Print Setup to print, but the end goal of this report is to be emailed to customers as a PDF, and guess what, when I set the margins manually and exported, it still split into 6 pages and bombed out. So risking everything, I tried one last supreme effort to fix this blasted thing - I opened up the .rdlc with word pad, and miracle of miracles, found 1in, etc. I set all those buggers to 0in, saved, ran my .net code (2008), opened up Print Setup, and hallelujah, there was my 0in settings. Now for the supreme test - I exported it as a PDF, went to the file, and son of a gun! Sweet. There were two crisp clean perfectly laid out pages. All was beneficent in the universe, I calmed down and let the midiclorians flow through me, and just basked in a moment so rare that it is rarely realized by some - a simple fix.
查看ReportPageSettings 类,报表查看器控件的一部分。设置这些值看起来应该可以满足您的需要。
Check out the ReportPageSettings class, part of the report viewer control. Setting those values looks like it should get you what you need.
更多设置;
More settings;
这段代码适用于我,mm 中的数字
使用 vb.net 2013
this code work with me, the numbers in mm
im using vb.net 2013