Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

Example

The code below shows how to change the ReportTitle property:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ReportTitle := 'Summary Report';

Crpe1.Output := toWindow;

Crpe1.Execute;

SectionFont

Declaration

property SectionFont: TCrpeSectionFont;

Type

TCrpeSectionFont = class(TPersistent)

Description

The SectionFont object contains the properties that can be used to change the Font used in a Report section. Font styles can not be changed on a field by field basis, but only for a complete section at a time, although you can specify whether the changes should affect database fields, text fields, or both.

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RHa means ReportHeader "a", GH3b means GroupHeader 3b, etc. See About Section Names, Volume 1, Chapter 7, for more information.

The Retrieve method can be used to fill the SectionFont object with the Report sections. It is not actually possible to retrieve Font information, so the Retrieve method simply gathers the Section names, and sets the other SectionFont properties to default.

The Count method yields the number of SectionFont items contained in the SectionFont object.

The default array property, Item, or the ItemIndex property can be used to navigate through the sections (as well as the Section property).

The Font name can be set using the Name property, which is a property of the Delphi type: TFontName.

The size of the Font is controlled by the Size property.

The three attributes Italic, StrikeThrough, and Underlined can be set through those properties.

Bold is controlled by the Weight property.

The Pitch property determines if the Font spacing is fixed or variable.

The CharSet property determines which character set is used for the upper ASCII characters.

VCL Reference

90

The Family property specifies the Font family.

The Scope property specifies whether the Font changes are to affect database fields, or text fields, or both.

The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).

SectionFont Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section and sets various options for that section:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do begin

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman'; Crpe1.SectionFont[cnt].Size := 10; Crpe1.SectionFont[cnt].Pitch := fpDefault; Crpe1.SectionFont[cnt].Scope := Both; Crpe1.SectionFont[cnt].CharSet := fcDefault; Crpe1.SectionFont[cnt].Family := ffDefault; Crpe1.SectionFont[cnt].Italic := cTrue; Crpe1.SectionFont[cnt].StrikeThrough := cFalse; Crpe1.SectionFont[cnt].Underlined := cFalse; Crpe1.SectionFont[cnt].Weight := fwBold;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

The following sample retrieves the SectionFont sections from the Report, and then changes the Text fields in the Group Header to Times New Roman font, 12 point size:

Crpe1.ReportName := 'MyReport.rpt';

Crpe1.SectionFont.Retrieve;

Crpe1.SectionFont.Section := 'GH1';

Crpe1.SectionFont.Name := 'Times New Roman';

Crpe1.SectionFont.Size := 12;

Crpe1.SectionFont.Scope := Text;

Crpe1.Execute;

VCL Reference

91

SectionFont Properties

SectionFont CharSet property, Page 527 SectionFont Family property, Page 528 SectionFont Italic property, Page 529 SectionFont Item property, Page 530 SectionFont ItemIndex property, Page 531 SectionFont Name property, Page 531 SectionFont Pitch property, Page 532 SectionFont Scope property, Page 533 SectionFont Section property, Page 534 SectionFont SectionAsCode property, Page 535 SectionFont Size property, Page 536 SectionFont StrikeThrough property, Page 537 SectionFont Underlined property, Page 538 SectionFont Weight property, Page 539

SectionFont Methods

SectionFont Add method, Page 540 SectionFont Clear method, Page 541 SectionFont CopyFrom method, Page 541 SectionFont Count method, Page 542 SectionFont Create method, Page 542 SectionFont Delete method, Page 543 SectionFont Destroy method, Page 543 SectionFont Retrieve method, Page 543 SectionFont SectionType method, Page 544 SectionFont Send method, Page 545

VCL Reference

92

Соседние файлы в папке crystal