Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Displaying cross tab data?
Message
From
26/07/2007 13:52:03
 
 
To
26/07/2007 11:06:40
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Miscellaneous
Thread ID:
01243774
Message ID:
01243866
Views:
35
>I am designing a report, and need to display cross-tabbed data. The data has already been pivoted. My task is to display this data that has an unknown number of columns at design time.
>
>Is there a solution for this problem?
>
>One thought I had was to build up HTML from the pivoted data, but I'm not sure if VFP report designer can display html.

Nancy Jacobsen published a solution to this problem in FoxTalk a long, long time ago (1990 or 1991, I think).

The basic idea is that you set up your report with as many columns as fit comfortably. In the calling program, you use code like:

nColumns = # of data columns in the report
nDataFields = FCOUNT() - 1 && first field is label
nPages = INT(nDataFields/nColumn) + 1

FOR nPage = 1 to nPages
REPORT FORM (YourReport)
ENDFOR

In the report, you use a complicated expression involving the FIELD() function and nPages to put the fields (and the headings) in place. It varies from column to column, but it's along these lines (this one is for the first data column):

IIF(TYPE(FIELD((nPage-1)*nColumns + 1)) <> "U", ;
FIELD((nPage-1)*nColumns + 1),"")

IOW, the first time through the loop, you report on data columns 1 through nColumns. The second time, it's nColumns + 2 up to 2*nColumns, etc.

The expression for the data checks whether there's a field to report on in this column and if so, shows the data.

Hope this helps.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform