Changelog:
- New: Report(cQuery,cTitle,aHeaders,aWidths,aJustify,cPdfName,lPreview,aFormats) method.
Creates a PDF report from a MySql Query.
Returns: .T. if it was successful (.F. otherwise).
For PDF generation it uses a slightly modified version of the original HMG_HPDF by
Rathinagiri. I've renamed the source file and internal functions to avoid conflicts
with any other version of it.
Example:
Code: Select all
cCommand := 'SELECT code,description,location,stock,price FROM hmgtest ORDER BY code'
cTitle := 'STOCK REPORT'
aHeaders := { 'CODE', 'DESCRIPTION', 'LOCATION', 'STOCK', 'PRICE' }
aWidths := { 6,32,32,6,12 }
aJustify := { 'C','L', 'L','R','R'}
cPdfName := 'stock' + '.' + dtos(date()) + '_' + alltrim(str(int(seconds())))
lPreview := .t.
aFormats := { {|x| STRZERO(x,4)},{|x|UPPER(x)},{|x|UPPER(x)},NIL,{|x|TRANSFORM(x,'999,999.99')} }
IF !:Report(cCommand,cTitle,aHeaders,aWidths,aJustify,cPdfName,lPreview,aFormats)
RETURN
ENDIF
- New: Export(cQuery,cOutFile,aFormats,cDelimiter,lQuote) method.
Creates a CSV file from a MySql Query.
Returns: .T. if it was successful (.F. otherwise).
Example:
Code: Select all
cQuery := 'SELECT * FROM hmgtest ORDER BY code'
cOutFile := 'hmgtest.csv'
* aFormats (optional)
aFormats := { {|x| STRZERO(x, 4)},{|x| STRZERO(x, 4)}, {|x| UPPER(x) },NIL,NIL,{|x| TRANSFORM(x,'999,999.99') } }
* cDelimiter is optional (default is ';')
cDelimiter := NIL
* Quote is optional (default is .F.)
lQuote := NIL
IF !:Export(cQuery,cOutFile,aFormats,cDelimiter,lQuote)
RETURN
ENDIF
I hope this be useful for someone.