一个qreport的例子:中文多行显示,表格线在多行显示时的扩展,扩展之后的手动分页,文本式的反向报表(试过)
2006-10-01 12:19
369 查看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, QRCtrls, ExtCtrls, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
ADOTable1: TADOTable;
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
meCutWord: TMemo;
QRDBText2: TQRDBText;
QRShape1: TQRShape;
QRDBText1: TQRDBText;
Label1: TLabel;
QRShape2: TQRShape;
QRLabel1: TQRLabel;
procedure QRDBText1Print(sender: TObject; var Value: String);
procedure FormCreate(Sender: TObject);
procedure DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
private
{ Private declarations }
public
{ Public declarations }
hhh: array of Extended; // 用来记录每条记录扩充的高度
end;
const
MAXLEN= 21;
var
Form1: TForm1;
rows : integer;
implementation
{$R *.dfm}
(* DetailBand1AfterPrint, QuickRep1BeforePrint ,DetailBand1BeforePrint
都是用来当多行显示的时候,qrdbtext将向下扩展,这时默认情况下,qrshape是不会向下扩展的,
上述三个处理就是用来解决这个问题的。
此外,还用到 rows : integer;
hhh: array of Extended;
setlength(hhh, 1000); //1000是代表的记录的总数,这里用1000是一个大概的表示。
//可以的话应该精确表示,以避免空间的浪费
quickRep1.Prepare;
*)
procedure TForm1.QRDBText1Print(sender: TObject; var Value: String);
var
I: Integer;
text:TQRDBText;
begin
//解决中文多行显示的问题。
//dbtext.autosize:= false;
//dbtext.autostretch := true;
//dbtext.wrap := true;
text := sender as TQRDBText;
meCutWord.Font.Assign(text.Font); // 指定字型
meCutWord.Width := text.Width;// 指定寬度
meCutWord.Lines.Clear;// 清除上一次的東西
meCutWord.Lines.Text := Value; // 把 value assign 進去
Value := meCutWord.Lines.Strings[0];
for I := 1 to meCutWord.Lines.Count - 1 do
begin
Value := Value + #13 + meCutWord.Lines.Strings[i];// 逐行取出再塞回去
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
setlength(hhh, 1000);
QuickRep1.Prepare;
quickRep1.PreviewModal;
end;
procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
hhh[rows] := QuickRep1.bands.DetailBand.Expanded;
rows := rows + 1;
end;
procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
var
i:integer;
begin
rows := 1;
for I := 0 to quickrep1.Bands.DetailBand.ControlCount - 1 do // Iterate
begin
if QuickRep1.Bands.DetailBand.Controls[i] is TQRShape then
(QuickRep1.Bands.DetailBand.Controls[i] as TQRShape).Height :=
QuickRep1.Bands.DetailBand.Height;
end; // for
end;
procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
var
i:Integer;
begin
for I := 0 to quickrep1.Bands.DetailBand.ControlCount - 1 do // Iterate
begin
if QuickRep1.Bands.DetailBand.Controls[i] is TQRShape then
begin
(QuickRep1.Bands.DetailBand.Controls[i] as TQRShape).top := 1;
(QuickRep1.Bands.DetailBand.Controls[i] as TQRShape).Size.Height :=
QuickRep1.Bands.DetailBand.Size.Height + hhh[rows];
end;
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, QRCtrls, ExtCtrls, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
ADOTable1: TADOTable;
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
meCutWord: TMemo;
QRDBText2: TQRDBText;
QRShape1: TQRShape;
QRDBText1: TQRDBText;
Label1: TLabel;
QRShape2: TQRShape;
QRLabel1: TQRLabel;
procedure QRDBText1Print(sender: TObject; var Value: String);
procedure FormCreate(Sender: TObject);
procedure DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
private
{ Private declarations }
public
{ Public declarations }
hhh: array of Extended; // 用来记录每条记录扩充的高度
end;
const
MAXLEN= 21;
var
Form1: TForm1;
rows : integer;
implementation
{$R *.dfm}
(* DetailBand1AfterPrint, QuickRep1BeforePrint ,DetailBand1BeforePrint
都是用来当多行显示的时候,qrdbtext将向下扩展,这时默认情况下,qrshape是不会向下扩展的,
上述三个处理就是用来解决这个问题的。
此外,还用到 rows : integer;
hhh: array of Extended;
setlength(hhh, 1000); //1000是代表的记录的总数,这里用1000是一个大概的表示。
//可以的话应该精确表示,以避免空间的浪费
quickRep1.Prepare;
*)
procedure TForm1.QRDBText1Print(sender: TObject; var Value: String);
var
I: Integer;
text:TQRDBText;
begin
//解决中文多行显示的问题。
//dbtext.autosize:= false;
//dbtext.autostretch := true;
//dbtext.wrap := true;
text := sender as TQRDBText;
meCutWord.Font.Assign(text.Font); // 指定字型
meCutWord.Width := text.Width;// 指定寬度
meCutWord.Lines.Clear;// 清除上一次的東西
meCutWord.Lines.Text := Value; // 把 value assign 進去
Value := meCutWord.Lines.Strings[0];
for I := 1 to meCutWord.Lines.Count - 1 do
begin
Value := Value + #13 + meCutWord.Lines.Strings[i];// 逐行取出再塞回去
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
setlength(hhh, 1000);
QuickRep1.Prepare;
quickRep1.PreviewModal;
end;
procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
hhh[rows] := QuickRep1.bands.DetailBand.Expanded;
rows := rows + 1;
end;
procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
var
i:integer;
begin
rows := 1;
for I := 0 to quickrep1.Bands.DetailBand.ControlCount - 1 do // Iterate
begin
if QuickRep1.Bands.DetailBand.Controls[i] is TQRShape then
(QuickRep1.Bands.DetailBand.Controls[i] as TQRShape).Height :=
QuickRep1.Bands.DetailBand.Height;
end; // for
end;
procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
var
i:Integer;
begin
for I := 0 to quickrep1.Bands.DetailBand.ControlCount - 1 do // Iterate
begin
if QuickRep1.Bands.DetailBand.Controls[i] is TQRShape then
begin
(QuickRep1.Bands.DetailBand.Controls[i] as TQRShape).top := 1;
(QuickRep1.Bands.DetailBand.Controls[i] as TQRShape).Size.Height :=
QuickRep1.Bands.DetailBand.Size.Height + hhh[rows];
end;
end;
end;
end.
相关文章推荐
- 请问如何在Web页面中点击一个button之后,用jsp从数据库中读取数据显示到表格里
- 【matplotlib 】中文显示-负号显示(一个统计微信好友性别,饼图显示的例子)
- 网上找到一个用不同颜色显示表格奇偶行的例子
- java中显示列表有很多成型的组件,但我喜欢RICO一个开源的报表显示组件(javascript)的不分页显示
- 一个简单的点击后显示与隐藏表格的例子
- 需要这样一个记事本-14 ReportViewer在多页报表情况下,每页都显示表格列表头
- 一个用存储过程实现数据分页显示的例子,有更合适的请朋友们跟帖啊
- 网上找到一个用不同颜色显示表格奇偶行的例子
- 一个自定义的可以分页,排序,扩展显示grid控件
- 网上找到一个用不同颜色显示表格奇偶行的例子
- 一个可以左右滑动分页显示的例子(并带有页面图标指示)
- 整合了一个PHP分页函数与smarty与程序显示的例子
- 网上找到一个用不同颜色显示表格奇偶行的例子
- 网上找到一个用不同颜色显示表格奇偶行的例子
- 网上找到一个用不同颜色显示表格奇偶行的例子
- Qreport分组显示报表 (QRexp控件应用)
- 一个需要手动释放引用,避免内存溢出的例子
- 如何把报表放到网页中显示(Web页面与报表简单集成例子)
- android 使用tablelayout设计一个 天气 表格显示
- Torque游戏引擎全面支持Unicode,官方展示了一个有趣的中文例子(Torque support Unicode)