Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Crosstab Question

edited January 2008 in General
Hi,

I have been doing three crosstab reports that need to be displayed
sequentially. Because each report will have to be destroyed after
previewing, I decided that I would create the reports in code.

I have done the basic crosstabs. For example, I run a query that returns
fields STATUS, ENGINEER and JOBNO, then store the query results in a table
called Slideshow123.adt. Then I do:-

lTable := TAdsTable.Create(Self);
lTable.Name := 'tblCustomer1';
lTable.DatabaseName := 'AdsTempConnection';
lTable.TableType := ttAdsADT;
lTable.TableName := 'Slideshow123';

lDataSource := TDataSource.Create(Self);
lDataSource.Name := 'dsCustomer';
lDataSource.DataSet := lTable;

lDataPipeline := TppDBPipeline.Create(Self);
lDataPipeline.Name := 'plCustomer';
lDataPipeline.DataSource := lDataSource;

lReport := TppReport.Create(Self);
lReport.CreateDefaultBands;

lCrossTab := TppCrossTab.Create(Self);
lCrossTab.Band := lReport.DetailBand;
lCrossTab.UserName := 'CrossTab1';
lCrossTab.DataPipeline := lDataPipeline;
lCrossTab.InitAvailableDimensions;
lCrossTab.Stretch := True;
lCrossTab.Style := 'Standard';
lCrossTab.spLeft := 2;
lCrossTab.spTop := 2;
lColumnDef := lCrossTab.SelectColumnDef(
lCrossTab.IndexOfAvailableDimension('STATUS'));
lRowDef := lCrossTab.SelectRowDef(
lCrossTab.IndexOfAvailableDimension('ENGINEER'));
lValueDef := lCrossTab.SelectValueDef(
lCrossTab.IndexOfAvailableDimension('JOBNO'));
lValueDef.CalcType := dcCount;

Then I set the display options for the report and print it.

I just have to take a couple more steps. I need to put extra columns to the
right of the Grand Total column which are calculated from the Grand Total
for the row. The first extra column needs to show the Grand Total - 40.
The second extra column needs to show the value in the second column of the
basic crosstab, divided by the Grand Total, as a percentage. I can't figure
out how to do this!

Also I need to colour individual cells in the basic crosstab, depending on
their value. I have managed to colour the entire centre part of the
crosstab, but not individual cells.

I would be grateful if someone could help me with this. Perhaps there is an
example which will help?
--
Regards

Martin Houlton
P C Data Services

Comments

  • edited January 2008
    Hi again,

    I forgot to say I am using Delphi 6 and Reportbuilder Enterprise Edition v
    9.03.
    --
    Regards

    Martin Houlton
    P C Data Services
  • edited January 2008
    Hi Martin,

    It is possible to individually highlight a given cell in a crosstab using
    the OnFormatCell event. Take a look at demo 126 located in the
    \RBuilder\Demos\2. CrossTabs\... directory for an example of this.

    The built-in crosstab component is unfortunately not very customizable in
    that it would most likely take some source code modification to allow the
    addition of a new column or row with separate calculations. One option
    would be to perhaps add any additional rows or columns manually using line,
    shape, and text drawcommands.

    Another option would be to check out GridPack. This third party component
    pack contains a more advanced crosstab component that may allow this type of
    addition.

    http://www.planitechnologies.com/

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.