1.1 报表格式
1)水晶报表文字大小及格式:
(1) 报表头
文字大小:18号
字体:宋体
样式:常规
文字:居中
文字颜色:黑色
(2) 标题
文字大小:11号
字体:宋体
样式:常规
文字:居中
文字颜色:黑色
(3) 内容
文字大小:10号
字体:宋体
样式:常规
文字:居中(固定长度的文字,如:日期、物品单位、姓名等)
左对齐(无固定长度文字)
右对齐(数字类型,如:数量);
文字颜色:黑色
(4) 页脚
除非特殊情况下页脚都要显示以下信息
文字大小:12号
字体:宋体
样式:常规
文字:居中
1.2 报表每页显示行数
1) 横向显示行数
每页显示行数:24
2) 纵向显示行数
每页显示行数:33
3) 核心代码
recordnumber mod 24=0
1.3 报表横向、纵向打印设置
1) 打印机横向设置
设置—>打印机设置
注意:无打印机一定要选中(此处如果选择打印,显示的时候页面数据将不能完全显示)
2) 横向打印代码
RegRdt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
3) 纵向打印
请参考1)
4) 纵向打印代码
纵向打印不需要进行设置,系统默认。
1.4 释放报表文档资源
1) 释放报表资源
为了节约系统资源,在打印页数比较多的情况下打印需要释放报表资源,代码如下:
protected void Page_UnLoad(object sender, EventArgs e)
{
//建立完页面时,释放报表文档资源
RegRdt.Dispose();
this.Dispose();
this.ClearChildState();
}
1.5 报表引入名词空间
1) 报表引入名词空间
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
1.6 水晶报表横向打印BUG处理
1) crystalprinthost.html
if (window.dialogArguments.pageorientation) {
objectTag +="<PARAM NAME=/"PageOrientation/" VALUE=/"";
objectTag += window.dialogArguments.pageorientation;
objectTag += "/">";
}
这是一个js方法中的代码和水晶报表的源代码不对,在这里只要对这部分代码进行修改就可以如下:
if (window.dialogArguments.paperorientation ) {
objectTag +="<PARAM NAME=/"PageOrientation/" VALUE=/"";
objectTag += window.dialogArguments.paperorientation;
objectTag += "/">";
}
2) 文件存放位置
(1)/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/html
(2)C:/Inetpub/wwwroot/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/html
1.7 水晶完整示例代码
1) 核心代码
private void BindPrint()
{
DataTable dt = new DataTable();
this.crv.PageToTreeRatio = 876; //设置组树大小与视图之间的比例
QueryCondition qc = new QueryCondition();
message = new BInOutDetail().GetInOutMessage(ref dt, GetBillIdCondition());
if (message != null)
{
MessageCode("sys003");
return;
}
//报表打印时自动为横向打印设置
RegRdt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
RegRdt.Load(Server.MapPath("CrvInWareHouseInfo.rpt")); //加载报表文件
RegRdt.SetDataSource(dt); //数据绑定到报表
crv.ReportSource = RegRdt; //绑定报表源
#region 设置报表标题参数
string billDate = Request.QueryString["billDate"];
string billNo = Request.QueryString["billNo"];
string billUser =Server.UrlDecode( Request.QueryString["billUser"]);
string checkUser = Server.UrlDecode(Request.QueryString["checkUser"]);
string approveUser = Server.UrlDecode(Request.QueryString["billUser"]);
RegRdt.SetParameterValue("billDate", billDate); //绑定参数
RegRdt.SetParameterValue("billNo", billNo);
RegRdt.SetParameterValue("billUser", billUser);
RegRdt.SetParameterValue("checkUser", checkUser);
RegRdt.SetParameterValue("approveUser", approveUser);
#endregion
crv.DataBind();
}
private ReportDocument RegRdt = new ReportDocument();//声明报表对象
//释放报表,如出现打印的页多的情况下不释放将打印不能完成,只能打印一部分,别的不能打印。
protected void Page_UnLoad(object sender, EventArgs e)
{
//建立完页面时,释放报表文档资源
RegRdt.Dispose();
this.Dispose();
this.ClearChildState();
}
2) 前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CollectDetailPrint.aspx.cs" Inherits="WareHouse_Stat_CollectDetailPrint" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>仓库管理</title>
<link href="../../_CSS/Common.css" rel="stylesheet" type="text/css">
<script src="../../_Scripts/Calendar.js" type="text/javascript"></script>
<base target="_self" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="Table1" cellspacing="0" cellpadding="0" align="center" border="1">
<tr>
<td colspan="4">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr bgcolor="#4073B6">
<td style="height: 24px;">
<img alt="" src="../../_Images/GridView/titleIconDiamond.gif" />
<span style="color: #ffffff" runat="server" id="spanMessage"><strong>物品领用明细打印</strong>
<span style="color: #000000"></span></span>
</td>
</tr>
&