RDLC报表(六)


你可能已经注意到了在调用LocalReport的Render方法时用到了一个XML格式的DeviceInfo结构,在SQL Server 2005 Report Services中,DeviceInfo结构是为了给特定的呈现格式传递参数。来看一个简单的DeviceInfo结构:

RDLC报表(六) - 了啦 - 了啦的博客 < DeviceInfo >
RDLC报表(六) - 了啦 - 了啦的博客
< OutputFormat > EMF </ OutputFormat >
RDLC报表(六) - 了啦 - 了啦的博客
< PageWidth > 21cm </ PageWidth >
RDLC报表(六) - 了啦 - 了啦的博客
< PageHeight > 29.70cm </ PageHeight >
RDLC报表(六) - 了啦 - 了啦的博客
< MarginTop > 2cm </ MarginTop >
RDLC报表(六) - 了啦 - 了啦的博客
< MarginLeft > 2cm </ MarginLeft >
RDLC报表(六) - 了啦 - 了啦的博客
< MarginRight > 2cm </ MarginRight >
RDLC报表(六) - 了啦 - 了啦的博客
< MarginBottom > 2cm </ MarginBottom >
RDLC报表(六) - 了啦 - 了啦的博客
</ DeviceInfo >

这个简单的DeviceInfo结构至少为LocalReport的Render方法指定了输出格式、页宽、页高、左边距、右边距、下边距信息,在我们使用PrintPage的方法将LocalReport呈现为EMF图片时,EMF图片在页面上显示的大小、边距就是由这个DeviceInfo结构来决定的,如果为DeviceInfo结构和PrintDocumnt设置不匹配的页面大小或边距,那么在PrintPage事件中使用DrawImage方法画出的图片将出现放大或缩小的情况,这是我们不愿意看到的结果。也就是说,在使用自定义纸张进行单据打印时,我们不仅要为PrintDocument设置页面大小和边距,还要为LocalReport设置与PrintDocument相同的页面大小和边距。关于DeviceInfo的结构,可以参考http://msdn2.microsoft.com/zh-cn/library/ms155373.aspx

下面是我封装的一个为生成DeviceInfo结构使用的类:

RDLC报表(六) - 了啦 - 了啦的博客 using System;
RDLC报表(六) - 了啦 - 了啦的博客
using System.Collections.Generic;
RDLC报表(六) - 了啦 - 了啦的博客
using System.Text;
RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
namespace RDLCReport
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
public class EMFDeviceInfo
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
private bool m_Landscape = false;
RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
public bool Landscape
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
get
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
return this.m_Landscape;
RDLC报表(六) - 了啦 - 了啦的博客 }

RDLC报表(六) - 了啦 - 了啦的博客
set
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
this.m_Landscape = value;
RDLC报表(六) - 了啦 - 了啦的博客 }

RDLC报表(六) - 了啦 - 了啦的博客 }

RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
/*
RDLC报表(六) - 了啦 - 了啦的博客 * The pixel depth of the color range supported by the image output.
RDLC报表(六) - 了啦 - 了啦的博客 * Valid values are 1, 4, 8, 24, and 32.
RDLC报表(六) - 了啦 - 了啦的博客 * The default value is 24.
RDLC报表(六) - 了啦 - 了啦的博客 * ColorDepth is only supported for TIFF rendering and is otherwise ignored by the report server for other image output formats.
RDLC报表(六) - 了啦 - 了啦的博客 * Note:
RDLC报表(六) - 了啦 - 了啦的博客 * For this release of SQL Server, the value of this setting is ignored, and the TIFF image is always rendered as 24-bit.
RDLC报表(六) - 了啦 - 了啦的博客 *
RDLC报表(六) - 了啦 - 了啦的博客 * 默认值为24,且只有当输出格式为TIFF时才该项设置才起作用
RDLC报表(六) - 了啦 - 了啦的博客 *
RDLC报表(六) - 了啦 - 了啦的博客
*/

RDLC报表(六) - 了啦 - 了啦的博客
private int m_ColorDepth = 24;
RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
public int ColorDepth
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
get
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
return this.m_ColorDepth;
RDLC报表(六) - 了啦 - 了啦的博客 }

RDLC报表(六) - 了啦 - 了啦的博客 }

RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
/*
RDLC报表(六) - 了啦 - 了啦的博客 * The number of columns to set for the report. This value overrides the report's original settings.
RDLC报表(六) - 了啦 - 了啦的博客 *
RDLC报表(六) - 了啦 - 了啦的博客 * 未用到此项设置
RDLC报表(六) - 了啦 - 了啦的博客 *
RDLC报表(六) - 了啦 - 了啦的博客
*/

RDLC报表(六) - 了啦 - 了啦的博客
private int m_Columns = 0;
RDLC报表(六) - 了啦 - 了啦的博客
RDLC报表(六) - 了啦 - 了啦的博客
public int Columns
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
get
RDLC报表(六) - 了啦 - 了啦的博客
{
RDLC报表(六) - 了啦 - 了啦的博客
return this.m_Columns;
RDLC报表(六) - 了啦 - 了啦的博客 }

RDLC报表(六) - 了啦 - 了啦的博客
set
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值