Xreport 1.0

User's guide.


The XReport report tool for Kylix2 and Delphi6 RAD tool..


Introduction.

X-Report is a Kylix 2/Delphi 6 reporting tool component. It consists of a report engine, designer (design-time and runtime), and preview.


Features:


Requirements:

Kylix2 on linux, or Delphi6 on windows.


Installation:

If you downloaded it from the X-Szoft homepage (www.x-szoft.hu) unzip the archive to anywhere, if you have CD-ROM editation start the setup program directly from CD. The name of the setup program is setup.exe under windows, and setup under linux. The setup program will ask your name, your organization and activation key. If you have CD version you can find your activation key on the cover of the original CD, if not you can buy activation key from X-Szoft on-line. In this case, you must send your name and organization name, and we vill send your activation key.

If you remain empty the activation key on setup program, the system will be unregistered shareware ,after 60 days you will no longer be able to execute print or print preview procedures.

If you buy activation key to unregistered shareware version, you must re-run setup and recomplile all of your applications that are use this product.

The system architecture:

The most important part of the X-Report system is the TXReport component. With the properties of this component you can specify the basic attributes of report (Page size, margins, orientation) and with the compontnent editor you can visually design your report. You can also use this designer at run-time with the Design method, and save or load the visual design information with SaveToStream or LoadFromStream commands.


Using TXReport:

Just drop the component to a form. The double-click to the component on the form starts the

design-time designer. You can see the following picture:




The report layout helps to explore the structure of the report. With the control bar you can select a report control (label, memo, header, footer) that you want to drop to the report. The datasource and datafield listbox help you create data-bound controls: if you hold down the shift key and drop Label field to the report, the designer automatically fills the label's text proprerty with the DisplayName of the field. If you hold down the Ctrl key when drops Label or Memo field to the report, the designer fills the DataSource and DataField properties. You can also user Ctrl+Ins, Shift+Ins,Shift+Del to Copy, Paste, Cut commands.



Quick reference guide:


TXReport

This is the main component of Xreport report tool.


Properties:

LeftMargin

RightMargin

TopMargin

Bottommargin The left, right, top and bottom margins of the report.

Orientation The orientation of the report can be poPortrait and poLandscape.

PageSize The size of the report page.

FiststPage The first printable page.

LastPage The last printable page.

Copies The number of copies you want to print.


Methods:

Print It prints the report.

Preview It shows print preview on the screen.

Design You can design the report at run time.

LoadFromStream It loads design info from a stream.

SaveToStream It saves design info to a stream.

ExportToStream You can export the report to stream in CSV or HTML format.

ItemByName It finds the report item with a specified name.

LabelByName Like ItemByName but returns only TXRLabel.

MemoByName Like ItemByName but returns only TXRMemo.

ImageByName Like ItemByName but returns only TXRImage.

ShapeByName Like ItemByName but returns only TXRShape.

HeaderByName Like ItemByName but returns only TXRHeader.

FooterByName Like ItemByName but returns only TXRFooter.

ListByName Like ItemByName but returns only TXRList.

SublistByName Like ItemByName but returns only TXRSubList.

SummaryByName Like ItemByName but returns only TXRSummary.

DetailByName Like ItemByName but returns only TXRDetail.


Items of TXReport:

Band items


TXRList:

Parent of all other band item. You can drop TXRList to band items it will be sub-list with other data source, and make possible to create very complex report structure.


Properties:

DataSource. The datasource of the list.

Columns The number of columns of the list.

Columnspace The space between the columns.

Brush The background brush of the list.

Pen The background pen of the list. (border)

Picture You can define a background picture to the report.

Enabled You can enable or disable printing of the list.

Name The name of the list.

ListAlignment You can align the detail, summary, etc band items to top, center or

bottom of report.


Events:

OnBeforePrint Occurs before print TXRList.

OnAfterPrint Occurs after print TXRList.

OnPrintRecord Occurs before print the current record of DataSource.



TXRSubList

You can give sub list to Detail, Groupheader, Groupfooter or Summary bands. Similar to TXRList you can drop Header, Footer, Groupheader, Groupfooter and Summary items to this.


Properties:

DataSource. The datasource of the sub-list.

Name The name of the sub-list.

Enabled You can enable or disable printing of the list.


Events:

OnBeforePrint Occurs before print TXRList.

OnAfterPrint Occurs after print TXRList.

OnPrintRecord Occurs before print the current record of DataSource.



TXRHeader


If you drop it to list, it is a page header of the list, if you drop it to detail, it is the column header. On TXRSublist it is a sublist header. You can add more than one header to the list, but only one can be enabled.


Properties:

Brush The background brush of the header.

Pen The pen of the border.

Font The default pen of printable items on the header.

Options You can enable or disable the left,top, right,bottom line of border.

Enabled You can enable or disable printing of this header with this.

Name The name of the header.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.


TXRFooter


If you drop it to list, it is a page footer of the list, if you drop it to detail, it is the column footer. On TXRSublist it is a sublist footer. You can add more than one footer to the list, but only one can be enabled.


Properties:

Brush The background brush of the footer.

Pen The pen of the border.

Font The default pen of printable items on the footer.

Options You can enable or disable the left,top, right,bottom line of border.

Enabled You can enable or disable printing of this footer with this.

Name The name of the footer


Events:

OnBeforePrint and OnAfterPrint, like TXRList.


TXRDetail

It is the detail item of the list. The TXRList and TXRSublist draw it on every record of datasource.


Properties:

Brush The background brush of the detail.

Pen The pen of the border.

Font The default pen of printable items on the detail.

Options You can enable or disable the left,top, right,bottom line of border.

Enabled You can enable or disable printing of this detail with this.

Name The name of the detail item.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.



TXRGroupHeader

Printed at the begining of the group.


Properties:

Brush The background brush of the group header.

Pen The pen of the border.

Font The default pen of printable items on the group header.

Options You can enable or disable the left,top, right,bottom line of border.

Enabled You can enable or disable printing of this group header with this.

Name The name of the group header item.

GroupSource,Groupfield When the value of groupfield changes the group header will be visible.

GroupExpression If the value of expression changes the group header will show.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.



TXRGroupFooter

Printed at the end of the group.


Properties:

Brush The background brush of the group footer.

Pen The pen of the border.

Font The default pen of printable items on the group footer.

Options You can enable or disable the left,top, right,bottom line of border.

Enabled You can enable or disable printing of this group footer with this.

Name The name of the group footer item.

GroupSource,Groupfield When the value of groupfield changes the group footer will be visible.

GroupExpression If the value of expression changes the group footer will show.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.



TXRSummary

Printed after last detail.


Properties:

Brush The background brush of the summary.

Pen The pen of the border.

Font The default pen of printable items on the summary.

Options You can enable or disable the left,top, right,bottom line of border.

Enabled You can enable or disable printing of this detail with this.

Name The name of the summary.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.

Printable items:


TXRLabel:

It's a very simple label, similar to TLabel component.


Properties:


Autosize Determines whether the size of the label automatically resizes to accomodate the text.

Expression You can define an expression, the label item will evaluate it and display the result if SysData is txsExpression.

DataSource The datasource of the label.

DataField The datafield of the label.

Exportable You can enable or disable html or cvs export of the label

Font The font of the label.

Pen The pen of the label's background.

Brush The brush of the label's background.

Alignment Text alignment: can be left, right and center.

VertAlignment Vertical alignment, can be top, bottom or center.

Format If the DataField is numeric, you can give a format string to display it.

SysData You can define simple system data (like date, time, page number,

copy number, total pages of report, result of expression evaluation,

or you can instruct the TXRLabel to display summary of data.

FormattedSumValue When it's true, the summary will use the format string if you define it (you can decrese the precision)

Hint Tooltip to the designer.

Enabled You can hide the label with this property.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.



TXRMemo:

It's a memo item, similar to TMemo component.


Properties:

DataSource The datasource of the memo.

DataField The datafield of the memo.

Exportable You can enable or disable html or cvs export of the memo

Font The font of the memo.

Pen The pen of the memo's background.

Brush The brush of the memo's background.

Alignment Text alignment: can be left, right and center.

VertAlignment Vertical alignment, can be top, bottom or center.

Hint Tooltip to the designer.

CanGrow If it's true the memo can grow vertically.

MaxHeight If the memo can grow, you can give the maximal height.

WrapMode You can give word or char. wrap mode or none. (lines truncated)

Enabled You can show or hide the memo with this property.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.



TXRShape:

You can draw simple shape (line, ellipse, rectangle, etc)


Properties:

Pen The pen of the shape.

Brush The brush of the shape.

Hint Tooltip to the designer.

Enabled You can show or hide the shape with this property.

Shape The type of the shape: can be horizontal an vertical line,

rectangle, ellipse, roundrect.


Events:

OnBeforePrint and OnAfterPrint, like TXRList.


TXRPicture:

You can draw a picture with this item


Properties:

DataSource Datasource of the picture.

DataField DataField of the picture.

Picture You can give a static picture.

Exportable You can enable or disable html or cvs export of the picture


Events:

OnBeforePrint and OnAfterPrint, like TXRList.


TXRCheck:

Checkbox item.


Properties:

Exportable You can enable or disable html or cvs export of the checkbox

DataSource Datasource of the value.

DataField DataField of the value.

Text Value if DataSource and Datafield empty

ValueCheckled Specifies the value that corresponds the checked value of the item.

ValueUnChecked Specifies the value that corresponds the unchecked value of the item.

AllowGrayed If it is set to true the item has three state (checked,grayed and unchecked).


Events:

OnBeforePrint and OnAfterPrint, like TXRList.



TXRProgress:


You can draw a progress bar with this item


Properties:

DataSource Datasource of the position.

DataField DataField of the position.

Position The position if datasource and data field empty.

Max Upper limit of the range of possible positions.

Min Lower limit of the range of possible positions.

Brush The brush of filled area

Exportable You can enable or disable html or cvs export of the checkbox


Events:

OnBeforePrint and OnAfterPrint, like TXRList.


TXRBarcode


It is a sample wrapper of Andreas Schmidt's freeware Barcode component (http://members.tripod.de/AJSchmidt/index.html). Source code of my CLX port is included.

It works only under Kylix2 at this moment.


Properties:

DataSource Datasource of the text

DataField DataField of the text

Modul Width of smallest line of barcode

Ratio Ratio between a wide and a narrow line in a barcode

Checksum Enable or disable checksum calculation (CODE39, EAN8, EAN13)

ChecksumMethod The method of Checksum calculation

Color The color of background

ColorBar The color of bars

Orientation Horizontal or vertical

Text Text value

ShowText Enable or disable printing plain text

Typ Type of barcode

Exportable You can enable or disable html or cvs export of the checkbox


Events:

OnBeforePrint Like TXRLabel

OnAfterPrint

Expression syntax (Label and Group)


Operators:

<,>,<=,>=,!=,+,-,*,/,|,&

Notes:

<> is case sensitive, != is not.

& is a binary and, | is a binary or.

Result of boolean operators is numeric, the true value is 1, the false is 0.


Functions:


IF(numeric expr,value1,value2)

Returns value1 if expr is true or value2 if false.


numeric ABS(numeric value)

returns an absolute value


string CHAR(numeric code)

converts numeric code to ASCII code.


numeric ORD(string value);

retunrs the order of ASCII code of the first character of string


numeric VAL(string value)

converts string to number


string FORMATTEDNUMERIC(string format,numeric value)

you can format your number, like formatfloat function in Kylix2


numeric INT(numeric value)

returns of truncated value, like round function in Kylix2


string ENCODEDATE(numeric year,numeric month ,numeric day)

create string timestamp value, like similar Kylix2 function.


numeric YEAR(string timestamp)

returns the year of timestamp


numeric MONTH(string timestamp)

returns the month of timestamp


numeric DAY(string timestamp)

returns the day of timestamp


numeric DAYOFWEEK(string timestamp)

returns the day of week of timestamp


numeric DAYOFYEAR(string timestamp)

returns the day of year of timestamp


numeric WEEKOFYEAR(string timestamp)

returns the week of year of timestamp

numeric HOUR(string timestamp)

returns the hour of timestamp


numeric SECOND(string timestamp)

returns the second of timestamp


numeric MINUTE(string timestamp)

returns the minute of timestamp


string STR(numeric value)

converts numeric to string


string COPY(string src, numeric start, numeric length)

like Kylix copy function


number LENGTH(string value)

retunrs the length of string


string PRETTY(string value)

convert the first character words uppercase, other characters to lowercase and skip unnecessary spaces.


string UPPER(string value)

converts string uppercase


string LOWER(string value)

converts string lowercase


string DATE()

returns current date


string TIME()

returns current time


string SOUNDEX(string)

retunrs soundex of string


string NOW(numeric diffdays)

retunrs timestamp string of current datetime (Kylix now function+ diffdays)


numeric POS(string substr, string srcstring)

like POS function of Kylix


numeric SQRT(numeric value)

like SQRT of Kylix


numeric DIV(numeric op1, numeric op2)

retunrs op1 div op2


numeric MOD(numeric op1, numeric op2)

retunrs op1 mod op2

numeric DIFFDATE(string op1, string op2)

retunrs the number of days between a two timestamp string


SUM(datafield[,precision])

returns summary of datafield with the specified precision.


AVG(datafield,precision)

returns avarage value of datafield with the specified precision.


Extensions:


You can add new items to XReport. If you want to do it you must inherit your new item from

TXRPrintable (or TXRDbPrintable):


TSamplePrtItem = class(TXRPrintable)


You can override the Draw procedure to draw anything to this object:


procedure Draw(c:TXPrtCanvas); override;


You can draw to TXPrtCanvas with a following procedures:


procedure Line(x1,y1,x2,y2:integer);

procedure RRectangle(x1,y1,x2,y2,x,y:integer);

procedure Rectangle(x1,y1,x2,y2:integer);

procedure Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer);

procedure Arc(X, Y, W, H, Angle, AngleLength: Integer);

procedure Chord(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer);

procedure Chord(X, Y, W, H, Angle, AngleLength: Integer);

procedure Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer);

procedure Pie(X, Y, W, H, Angle, AngleLength: Integer);

procedure Polygon(const Points: array of TPoint; Winding: Boolean = False;

StartIndex: Integer = 0; NumPts: Integer = -1);

procedure Polyline(const Points: array of TPoint; StartIndex: Integer = 0;

NumPts: Integer = -1);

procedure PolyBezier(const Points: array of TPoint; StartIndex: Integer = 0);

procedure PolyBezierTo(const Points: array of TPoint; StartIndex: Integer = 0);

procedure Plot(X,Y:integer;Color:TColor);

procedure Ellipse(x1,y1,x2,y2:integer);

procedure Bitmap(x1,y1,x2,y2:integer;bmp:TBitmap);

procedure TextOut(x1,y1,x2,y2,x,y:integer;txt:string;align:integer);

procedure SetPen(p:TPen);

procedure SetBrush(b:TBrush);

procedure SetFont(f:TFont);


You must register your new item with the RegisterXRptObj procedure in the initialization section of your unit:


initialization


RegisterXRptObj('Extension',TSamplePrtItem,HInstance);


You need a 24x24 bitmap resource with same name of your new item.


If anything is not clear, you can see the source code of TXRBarcode component.


Using of extensions:


It's very simple. Just put your unit to any installed package and add the source of unit to project of appiclation that use the new item(s).