|
-
May 8th, 2005, 07:54 AM
#1
Thread Starter
Frenzied Member
Re: Best way to print reports ??
I will try exporting to .CSV and opening the .CSV with Excell. Then I can format using automation.
-
May 8th, 2005, 09:06 AM
#2
Re: Best way to print reports ??
David,
The logic to loop through an "array" of "report objects" and output data with the PRINTER object is really quite simple.
And the powerful thing about this is that you only have "one report app" to support forever.
We produce nearly 100 different reports with this single SUB at this point. For three distinct business lines.
And there are no limitations - as you get with any off the shelf product.
Here's a post from a couple of months ago about Crystal's limitations...
http://www.vbforums.com/showpost.php...1&postcount=25
So even though you say you are in a rush and need to produce this report now - do it with a loop and logic that you can use next time for your next report as well.
Here's a SELECT off of the REPORT_T table from one of our databases.
VB Code:
RptSP RptSeq RptWhat RptExtra1 RptExtra2 RptExtra3 RptExtra4 RptExtra5 RptText
---------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------------
rptGLTrial 1 10 0 0 0 0 0 NULL
rptGLTrial 2 1 0 0 0 0 0 Times New Roman
rptGLTrial 3 3 0 0 0 0 0 NULL
rptGLTrial 4 2 10 0 0 0 0 NULL
rptGLTrial 5 30 0 0 0 0 0 NULL
rptGLTrial 6 2 17 0 0 0 0 NULL
rptGLTrial 7 41 4900 0 0 0 0 GL Trial Balance
rptGLTrial 8 2 10 0 0 0 0 NULL
rptGLTrial 9 33 10500 0 0 0 0 NULL
rptGLTrial 10 20 2 0 0 0 0 NULL
rptGLTrial 11 41 5400 0 0 0 0 Town of Norwood
rptGLTrial 12 20 4 0 0 0 0 NULL
rptGLTrial 13 34 4750 0 0 0 0 NULL
rptGLTrial 14 20 6 0 0 0 0 NULL
rptGLTrial 22 4 0 0 0 0 0 NULL
rptGLTrial 23 41 1000 0 0 0 0 Account
rptGLTrial 24 41 2500 0 0 0 0 Description
rptGLTrial 26 41 8000 0 0 0 0 Debit Amt
rptGLTrial 27 40 10200 0 0 0 0 Credit Amt
rptGLTrial 28 20 9 0 0 0 0 NULL
rptGLTrial 29 31 11700 0 0 0 0 NULL
rptGLTrial 30 22 60 0 0 0 0 NULL
rptGLTrial 31 51 1000 0 0 0 0 NULL
rptGLTrial 32 51 2500 1 0 0 0 NULL
rptGLTrial 34 55 7500 2 16 1 0 NULL
rptGLTrial 35 54 9700 3 16 1 0 NULL
(26 row(s) affected)
rptSP = SPROC that will supply the RECORDSET for the report
First object - rptWhat = 10 - landscape (see prior post for list of items).
Next object - rptWhat = 1 - fontname, next = 3 - bold
Next = 2 - fontsize - get that size from the RPTEXTRA1 column - size = 10
To jump along - rptWhat = 41 - print text (GL Trial Balance) at twip position 4900
An important one is in RPTSEQ 30 - the header control - rptWhat = 22.
Basically what happens is for every row we grab from the recordset, we loop through this array.
First time through every object gets processed - simple SELECT/CASE statement.
Example of the CASE 1
Code:
Select Case prtItems(i, 1)
Case 1
Debug.Print " PrintReport>"; i; ") x="; objPrt.CurrentX; " y="; objPrt.CurrentY _
; " Font="; strItem(prtItems(i, 7))
objPrt.Font = strItem(prtItems(i, 7))
When we hit that HEADER CONTROL (rptWhat=22) spot we remember the "spot" itself and note the size of the page in print lines (60 in this example).
Next row from the recordset - we loop through all the items again, but we skip sequence 1 through 30 because they are related to the "header".
We only do 31 through 35 - printing the 4 columns of output from the recordset. They are columns 0, 1, 2 and 3. Columns 2 and 3 are numeric so we fit them to 16 digits and right justify. The 1 in RPTEXTRA4 for these report objects indicate they will be part of a grand total.
We count the number of lines output - when we hit 60 we eject the page and reset the HEADER BOOLEAN variable so that the next row gets all array items processed for it.
Like I said this is extremely simple BASIC code - nothing complex.
And you don't want mine - it would be harder to understand then it's worth.
Develop the report you have now with this basic concept. You will have less than 10 items in your SELECT/CASE statement and a simple loop.
Next report you want to produce - use the same loop and enhance the "RPTWHAT" items as you need to support new features.
-
May 8th, 2005, 09:38 AM
#3
Thread Starter
Frenzied Member
Re: Best way to print reports ??
The main header text is straight forward to do so no problem there. What I really want to do is throw an array at the Printer Object and get it to work minimally with just that. OK the array is not just an array of numbers but it will be an array of types. Call it 'Cell' where ...
VB Code:
Type Cell
DisplayedValue as String
UnderlyingValue as Long
Width as Long
Height as Long
IsAheader as Long
TextisVertical as Boolean ' We could make it any angle later
BackColor as long ' If no value it reverts to the default
ForeColor as long ' If no value it reverts to the default
End Type
GridToDisplay() as Cell
I already display my grid information from an underlying array and so all I need to do is pass the formatting of that array, and the data, over to 'GridToDisplay' and fire it at the Print Object - where hopefully all is taken care of for me.
Hight and Width of the final grid will have to be properties that are set before the 'GridToDisplay' array is sent for printing. Also Portrait and Landscape will need to be determined in advance.
I get the gist of where you are coming from with your report handler. I will be able to use that to control the type of report allocated to a specific area within my APP. Thank you for the insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|