| Subject |
Re: Report problem |
| From |
Edward Racht <eracht@yahoo.com> |
| Date |
Fri, 19 Aug 2022 17:10:09 -0400 |
| Newsgroups |
dbase.getting-started |
Hi Charlie,
I'm sticking my neck out on this one as I don't know any info about your
header or footer requirements.
but!!
Mervyn has written up the math used to determine - how many lines on a
page can be had.
I have enclosed copies of his recommendations from the report newsgroup.
search on his name and they will come up. Been a couple years back.
would help to have a screen shot of your product. you can blacken out
data for privacy.
ed
The detailband's renderOffset property gives the distance from the top
of
the page to the bottom of the detailband. If you use the detailband's
onRender event handler to save this value this will be the top of the
footerband after the last record for the customer has been printed. You
can now use the footerband's preRender event handler to calculate how
high
to make the footerband. Once you have done this you need to set the top
of the rectangle and the text control that prints the total. Once the
footerband has been rendered use its onRender event handler to reset the
footerband and its contents.
If you have a second, nested, group you would use its renderOffset value
to determine the top of the group1 footerband.
Mervyn.
********** Start of example code **********
if file('test_cust.dbf')
drop table test_cust
endif
if not file('test_cust.dbf')
create table test_cust (id autoinc,customer character(15),address
character(15))
insert into test_cust (customer,address) values ("Alpha","Wherever")
insert into test_cust (customer,address) values ("Beta","Somewhere")
insert into test_cust (customer,address) values
("Charlie","Elsewhere")
endif
if file('test_inv.dbf')
drop table test_inv
endif
if not file('test_inv.dbf')
create table test_inv (id autoinc,cust_id numeric(3,0),item
character(15),;
cost numeric(10,2))
insert into test_inv (cust_id,item,cost) values (1,"sdfsdfsd",35.00)
insert into test_inv (cust_id,item,cost) values (2,"fghgfhgfh",23.00)
insert into test_inv (cust_id,item,cost) values
(3,"gfhgfhgfh",343.00)
insert into test_inv (cust_id,item,cost) values (3,"ertetr",12.44)
insert into test_inv (cust_id,item,cost) values
(3,"gfhhgfhfgh",24.66)
insert into test_inv (cust_id,item,cost) values
(2,"fdgdfgdgdf",3434.00)
insert into test_inv (cust_id,item,cost) values (2,"sdfsfsf",22.00)
insert into test_inv (cust_id,item,cost) values (2,"fdgd",123.45)
insert into test_inv (cust_id,item,cost) values (2,"sdf",225.00)
insert into test_inv (cust_id,item,cost) values
(1,"ghjghjghj",324.43)
endif
** END HEADER -- do not remove this line
//
// Generated on 2014/08/28
//
local r
r = new test_invReport()
r.render()
class test_invReport of REPORT
with (this)
metric = 5 // Millimeters
autoSort = false
endwith
this.QUERY1 = new QUERY()
this.QUERY1.parent = this
with (this.QUERY1)
left = 119.0625
top = 19.05
sql= 'SELECT i.id, i.item, i.cost, c.customer, c.address '
sql += 'FROM Test_cust c INNER JOIN Test_inv i '
sql += 'ON (c.id = i.cust_id) '
sql += 'Order by c.customer '
active = true
endwith
this.STREAMSOURCE1 = new STREAMSOURCE(this)
this.STREAMSOURCE1.GROUP1 = new GROUP(this.STREAMSOURCE1)
with (this.STREAMSOURCE1.GROUP1)
groupBy = "customer"
endwith
with (this.STREAMSOURCE1.GROUP1.footerBand)
preRender = class::FOOTERBAND_PRERENDER
onRender = class::FOOTERBAND_ONRENDER
height = 33.0
endwith
this.STREAMSOURCE1.GROUP1.footerBand.RECTANGLE1 = new
RECTANGLE(this.STREAMSOURCE1.GROUP1.footerBand)
with (this.STREAMSOURCE1.GROUP1.footerBand.RECTANGLE1)
left = 108.4792
top = 8.2021
width = 35.7188
height = 15.0
text = ""
colorNormal = "BtnText/White"
endwith
this.STREAMSOURCE1.GROUP1.footerBand.TEXT1 = new
TEXT(this.STREAMSOURCE1.GROUP1.footerBand)
with (this.STREAMSOURCE1.GROUP1.footerBand.TEXT1)
height = 5.5563
left = 117.7396
top = 12.0
width = 19.3145
prefixEnable = false
text = {||this.parent.parent.agSum({||this.parent.rowset.fields[
"cost" ].value})}
endwith
with (this.STREAMSOURCE1.GROUP1.headerBand)
height = 4.4097
beginNewFrame = true
endwith
this.STREAMSOURCE1.GROUP1.headerBand.TEXTCUSTOMER1 = new
TEXT(this.STREAMSOURCE1.GROUP1.headerBand)
with (this.STREAMSOURCE1.GROUP1.headerBand.TEXTCUSTOMER1)
height = 5.2917
left = 7.6729
top = 0.7938
width = 26.9875
variableHeight = true
prefixEnable = false
text = {||this.form.query1.rowset.fields["customer"].value}
endwith
this.STREAMSOURCE1.GROUP1.headerBand.TEXTADDRESS1 = new
TEXT(this.STREAMSOURCE1.GROUP1.headerBand)
with (this.STREAMSOURCE1.GROUP1.headerBand.TEXTADDRESS1)
height = 5.2917
left = 56.0917
top = 0.7938
width = 26.9875
variableHeight = true
prefixEnable = false
text = {||this.form.query1.rowset.fields["address"].value}
endwith
with (this.STREAMSOURCE1.detailBand)
onRender = class::DETAILBAND_ONRENDER
height = 4.4097
endwith
this.STREAMSOURCE1.detailBand.TEXTID1 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTID1)
height = 5.2917
left = 6.8792
top = 2.1167
width = 20.6375
variableHeight = true
prefixEnable = false
alignHorizontal = 2 // Right
text = {||this.form.query1.rowset.fields["id"].value}
endwith
this.STREAMSOURCE1.detailBand.TEXTITEM1 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTITEM1)
height = 5.2917
left = 48.4187
top = 2.1167
width = 26.9875
variableHeight = true
prefixEnable = false
text = {||this.form.query1.rowset.fields["item"].value}
endwith
this.STREAMSOURCE1.detailBand.TEXTCOST1 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTCOST1)
height = 5.2917
left = 115.3583
top = 1.8521
width = 19.05
variableHeight = true
prefixEnable = false
alignHorizontal = 2 // Right
picture = "99999999.99"
text = {||this.form.query1.rowset.fields["cost"].value}
endwith
with (this.printer)
duplex = 1 // None
orientation = 1 // Portrait
paperSource = 7
paperSize = 9
resolution = 3 // Medium
color = 2 // Color
trueTypeFonts = 1 // Bitmap
endwith
this.PAGETEMPLATE1 = new PAGETEMPLATE(this)
with (this.PAGETEMPLATE1)
height = 296.986
width = 209.991
marginTop = 19.5792
marginLeft = 19.5792
marginBottom = 10.0
marginRight = 18.5208
gridLineWidth = 0
endwith
this.PAGETEMPLATE1.STREAMFRAME1 = new STREAMFRAME(this.PAGETEMPLATE1)
with (this.PAGETEMPLATE1.STREAMFRAME1)
height = 240.0
left = 6.35
top = 24.0771
width = 165.1
form.STREAMFRAME1 = form.pagetemplate1.streamframe1
endwith
this.PAGETEMPLATE1.TEXT1 = new TEXT(this.PAGETEMPLATE1)
with (this.PAGETEMPLATE1.TEXT1)
height = 5.2917
left = 28.3104
top = 8.7312
width = 32.8083
prefixEnable = false
text = "My Company"
form.TEXT1 = form.pagetemplate1.text1
endwith
with (this.reportGroup.footerBand)
height = 4.4097
endwith
with (this.reportGroup.headerBand)
height = 0.0
endwith
this.firstPageTemplate = this.form.pagetemplate1
this.form.pagetemplate1.nextPageTemplate = this.form.pagetemplate1
this.form.pagetemplate1.streamframe1.streamSource =
this.form.streamsource1
this.form.streamsource1.rowset = this.form.query1.rowset
function DETAILBAND_onRender
this.parent.parent.topOfFooter = this.renderOffset
return
function FOOTERBAND_onRender
this.height = 15
this.text1.top = 8.2
this.rectangle1.top = 12
return
function FOOTERBAND_preRender
this.height = 240 - this.parent.parent.parent.topOfFooter
this.text1.top = this.height-8.2
this.rectangle1.top = this.height-12
return
endclass
*********** End of example code *******
------------------------------
I have a report where once I get to a certain line, I need to either start
a new page (if the line would be printed on page 1), or, if I am already on
the second page, don't do anything. I am not sure how to do that.
This should be easy but it isn't because of a bug.
Setting the detailband's beginNewFrame property true in the detailband's
preRender event handler should do the job. Unfortunately the
beginNewFrame is only forced for the next line.
If you can identify the line before the line you want to be on the
second page then it is doable.
In the attached example if the code in the detailband preRender event
handler is commented out 38 lines will print on the first page. If you
test to check for 38 or higher the next id number will be on page 2
because dBASE was going to do a pagebreak anyway. If you test for
anything less than 38 the pagebreak will be forced and the next id
number will be on page 2.
function DETAILBAND_preRender()
if this.textid1.text() = 38 and this.parent.parent.reportpage = 1
this.beginNewframe := true
else
this.beginnewframe = false
endif
return
A forced beginNewFrame in a group headerband's preRender event handler
is respected before the headerband is rendered (which is as it should
be) so it may be possible to do something with a group if you can't
identify the line before the one you want on page two. This would
depend on how the rest of the report is put together and you would need
a field like an autoinc field to drive it.
clear
if file('test_nextpage.dbf')
// drop table test_nextpage
endif
if not file('test_nextpage.dbf')
create table test_nextpage (id autoinc,data character(15))
use test_nextpage
generate 50
use
endif
** END HEADER -- do not remove this line
//
// Generated on 2017-03-20
//
local r
r = new TEST_NEXTPAGEREPORT()
r.render()
class TEST_NEXTPAGEREPORT of REPORT
with (this)
autoSort = false
endwith
this.TEST_NEXTPAGE1 = new QUERY(this)
with (this.TEST_NEXTPAGE1)
left = 465.0
top = 420.0
sql = 'select * from "test_nextpage.DBF"'
requestLive = false
active = true
endwith
with (this.printer)
duplex = 1 // None
orientation = 1 // Portrait
paperSource = 7
paperSize = 1
resolution = 3 // Medium
color = 2 // Color
trueTypeFonts = 1 // Bitmap
endwith
this.PAGETEMPLATE1 = new PAGETEMPLATE(this)
with (this.PAGETEMPLATE1)
height = 15840.0
width = 12240.0
marginTop = 1080.0
marginLeft = 1080.0
marginBottom = 1080.0
marginRight = 1080.0
gridLineWidth = 0
endwith
this.PAGETEMPLATE1.STREAMFRAME1 = new STREAMFRAME(this.PAGETEMPLATE1)
with (this.PAGETEMPLATE1.STREAMFRAME1)
height = 11592.0
left = 360.0
top = 1365.0
width = 9360.0
form.STREAMFRAME1 = form.pagetemplate1.streamframe1
endwith
this.STREAMSOURCE1 = new STREAMSOURCE(this)
with (this.STREAMSOURCE1.detailBand)
preRender = class::DETAILBAND_PRERENDER
endwith
this.STREAMSOURCE1.detailBand.TEXTID1 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTID1)
height = 293.0
left = 675.0
top = -2.0
width = 1170.0
variableHeight = true
prefixEnable = false
alignHorizontal = 2 // Right
text = {||this.form.test_nextpage1.rowset.fields["id"].value}
endwith
this.STREAMSOURCE1.detailBand.TEXTDATA1 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTDATA1)
height = 293.0
left = 4290.0
top = -2.0
width = 2000.0
variableHeight = true
prefixEnable = false
text = {||this.form.test_nextpage1.rowset.fields["data"].value}
endwith
with (this.reportGroup.footerBand)
height = 250.0
endwith
with (this.reportGroup.headerBand)
height = 250.0
endwith
this.firstPageTemplate = this.form.pagetemplate1
this.form.pagetemplate1.nextPageTemplate = this.form.pagetemplate1
this.form.pagetemplate1.streamframe1.streamSource =
this.form.streamsource1
this.form.streamsource1.rowset = this.form.test_nextpage1.rowset
function DETAILBAND_preRender()
if this.textid1.text() = 34 and this.parent.parent.reportpage = 1
this.beginNewframe := true
else
this.beginnewframe = false
endif
return
endclass
------------------------------
|
|