Highlight cell in a cross tab?

hsmhsm
edited 4:38AM in FastReport 4.0
I have a cross tab that contains a name, followed by repeating pairs of columns for different things
eg
Name | A_pc1 | B_pc1 | A_pc2 | B_pc2 | A_pc3 | B_pc3 |
------------------------------------------------------
jim  |   4   |   5   |   3   |   2   |   7   |   7   |
ben  |   8   |   6   |   8   |   9   |   8   |   4   |
amy  |   3   |   4   |   5   |   2   |   5   |   5   |
fred |   6   |   2   |   3   |   7   |   3   |   7   |
sally|   9   |   7   |   1   |   3   |   6   |   8   |

I'd like to highlight each cell in the 'B' columns depending upon whether the value in the corresponding 'A' cell on its left is <, = or > than the value in the 'B' cell
(B value > A value highlight green, = highlight yellow and < highlight red)

So for example Jim's B_pc1 value would be highlighted green as it is more than his A_pc1 value.


I think I should be able to do this using the OnPrintCell() event and somehow manipulating the RowIndex, ColumnIndex, CellIndex parameters to create a reference to the cell on my left (but only if I am in a 'B' column !) and then use that to compare to my value.

However I don't really understand what the RowIndex, ColumnIndex, CellIndex refer to or how I can only process every other column ie the B columns.

Anyone any idea of the correct syntax?

Comments

  • edited 4:38AM
    hsm wrote: »
    However I don't really understand what the RowIndex, ColumnIndex, CellIndex refer to or how I can only process every other column ie the B columns.
    I'm not sure one can manipulate DBross cells using any syntax similar to standard matrix like Cells[i,j].
    But if you use a compiler to create your report and can work with a code (instead of FR script) then you should search through FR source files for text "Cross" and you'll find a lot of places to read, including some structures and methods of Cross type.

    If you don't want to search through FR sources, then you can try my method (or rather idea), which is not hi-tech, but it works.

    - declare 2 dimensional array, large enough for all cells (rows X columns)
    - in OnPrintCell event save a value (Memo.Value, Memo.Text) of the cell to that array using RowIndex, ColumnIndex
    - in the same event you can test the value of other (saved earlier) cells, like MyCells[RowIndex, ColumnIndex - 1]
    - pay attention that cells with no value (empty cell memo on a preview) will not fire OnPrintCell event and your 2-dim array may contain nulls !


    The above works when FR Engine prints row by rows cells from left to right. So take care of DownThenAcross property.
    I'm not sure if it works when Cross is splited into 2 or more pages.

    If have more than one value in a single cell then you must use CellIndex parameter.

    Both RowIndex, ColumnIndex are usually used to get information about Row / Column headers values.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.