【vfp开源代码栏目提醒】:网学会员为需要vfp开源代码的朋友们搜集整理了custrep.prg相关资料,希望对各位网友有所帮助!
* This test uses "characters" for units.
if used('CUSTOMER')
select CUSTOMER
else
select 0
use (_samples + 'DATA\CUSTOMER')
endif used('CUSTOMER')
set order to COUNTRY
set database to TESTDATA
* Create an SFReportFile object and set some properties.
loReport = newobject('SFReportFile', 'SFRepObj')
loReport.cReportFile = 'CUSTREP.FRX'
loReport.lSummaryBand = .T.
loReport.cFontName = 'Arial'
* Set the height of the page header band.
loPageHeader = loReport.GetReportBand('Page Header')
loPageHeader.nHeight = 8
* Set the height of the detail band.
loDetail = loReport.GetReportBand('Detail')
loDetail.nHeight = 1
* Set the height of the summary band.
loSummary = loReport.GetReportBand('Summary')
loSummary.nHeight = 3
* Insert a group band and put objects in it.
loReport.CreateGroupBand()
loGroup = loReport.GetReportBand('Group Header', 1)
loGroup.cExpression = 'CUSTOMER.COUNTRY'
loGroup.nHeight = 3
loGroup.lPrintOnEachPage = .T.
loGroup.nNewPageWhenLessThan = 4
loObject = loGroup.AddItem('Text')
loObject.cExpression = 'Country:'
loObject.nVPosition = 1
loObject.lFontBold = .T.
loObject = loGroup.AddItem('Field')
loObject.cExpression = 'CUSTOMER.COUNTRY'
loObject.nWidth = fsize('COUNTRY')
loObject.nVPosition = 1
loObject.nHPosition = 10
loObject.lFontBold = .T.
loGroupFooter = loReport.GetReportBand('Group Footer', 1)
loGroupFooter.nHeight = 2
* Insert column heading and field records into the appropriate band.
lnFields = afields(laFields)
for lnI = lnFields to 1 step -1
if not inlist(laFields[lnI, 1], 'COMPANY', 'CITY', 'MAXORDAMT')
adel(laFields, lnI)
dimension laFields[alen(laFields, 1) - 1, alen(laFields, 2)]
endif not inlist(laFields[lnI, 1], ...
next lnI
lnFields = alen(laFields, 1)
lnWidth = 0
for lnI = 1 to lnFields
* Get the attributes for the current column.
lcField = laFields[lnI, 1]
lcAField = 'CUSTOMER.' + lcField
lcColumn = dbgetprop(lcAField, 'Field', 'Caption')
if empty(lcColumn)
lcColumn = proper(strtran(lcField, '_', ' '))
endif empty(lcColumn)
if laFields[lnI, 2] $ 'NFIBY'
lcAlign = 'Right'
lnFieldWidth = iif(laFields[lnI, 2] $ 'IBY', 12, laFields[lnI, 3])
lcPicture = '9,999,999.99'
else
lcAlign = 'Left'
lnFieldWidth = laFields[lnI, 3]
lcPicture = ''
endif laFields[lnI, 2] $ 'NFIBY'
* Determine the horizontal and vertical positions.
lnHPos = lnWidth
* Insert the column heading.
loObject = loPageHeader.AddItem('Text')
loObject.cExpression = lcColumn
loObject.nVPosition = 5
loObject.nHPosition = lnHPos
loObject.lFontBold = .T.
if lcAlign = 'Right'
loObject.nHPosition = lnHPos + lnFieldWidth - len(lcColumn)
endif lcAlign = 'Right'
loObject.cAlignment = lcAlign
* Insert the field.
loObject = loDetail.AddItem('Field')
loObject.cExpression = lcAField
loObject.nWidth = lnFieldWidth
loObject.nVPosition = 0
loObject.nHPosition = lnHPos
loObject.cAlignment = lcAlign
loObject.cPicture = lcPicture
* If this is a numeric field, update the summary band and the appropriate
* group band footer.
if laFields[lnI, 2] $ 'NFIBY'
loObject.cDataType = 'N'
lnVPos = loSummary.nHeight - 1
loObject = loGroupFooter.AddItem('Field')
loObject.cExpression = lcAField
loObject.nWidth = lnFieldWidth + 2
loObject.nVPosition = 1
loObject.nHPosition = lnHPos - 2
loObject.cAlignment = lcAlign
loObject.nResetOnGroup = 1
loObject.cTotalType = 'Sum'
loObject.cPicture = lcPicture
loObject.lFontBold = .T.
loObject.cDataType = 'N'
loObject = loSummary.AddItem('Field')
loObject.cExpression = lcAField
loObject.nWidth = lnFieldWidth + 2
loObject.nVPosition = 2
loObject.nHPosition = lnHPos - 2
loObject.cAlignment = lcAlign
loObject.cTotalType = 'Sum'
loObject.cPicture = lcPicture
loObject.lFontBold = .T.
loObject.cDataType = 'N'
endif laFields[lnI, 2] $ 'NFIBY'
* Increment the current horizontal position.
lnWidth = lnHPos + lnFieldWidth + 1
next lnI
lnWidth = lnWidth - 1
* Insert the page header.
loObject = loPageHeader.AddItem('Field')
loObject.cExpression = '"Customer Report"'
loObject.nWidth = lnWidth
loObject.nHPosition = 0
loObject.nVPosition = 0
loObject.cAlignment = 'Center'
loObject.lFontBold = .T.
* Insert the date.
loObject = loPageHeader.AddItem('Field')
loObject.cExpression = 'date()'
loObject.nWidth = 10
loObject.nHPosition = 0
loObject.nVPosition = 2
loObject.lFontBold = .T.
* Insert the pag