Page 1 of 1
written report with customized content, records changes
Posted: Sat Dec 04, 2010 10:33 am
by nguyenchiduc
Hi all
I have written a report for my job. Content changes according to records, and form requested by my boss. I'm happy because HMG3 have done.
You can also write a report specific to your job.
Note: need to align the coordinates of @ x, y of the
PRINT command to display exactly as required. Write the command to automatically loop when new page
Code: Select all
/* commands*/
select database
select printer default preview
START PRINTDOC
START PRINTPAGE
DO WHILE. NOT. EOF()
IF test == .T.
START PRINTPAGE
@x,y print "...content..."
ELSE
@x,y print "...content..."
END PRINTPAGE
ENDIF
ENDDO
/* commands*/
@x,y print "...content..."
END PRINTPAGE
END PRINTDOC
Below is screenshot:
Example 1 :
Example 2 :

Re: written report with customized content, records changes
Posted: Sat Dec 04, 2010 5:45 pm
by nguyenchiduc
You also can export from
.dbf to
.html file and write, draw something in.
Example : export from .dbf file to c:\temp\Export.html
Code: Select all
#include "hmg.ch"
#include "Fileio.ch"
FUNCTION MAIN
REQUEST DBFCDX
get_file()
DEFINE WINDOW Main_form AT 1,1 WIDTH 2 HEIGHT 2 MAIN
END WINDOW
RETURN
PROCEDURE get_file()
LOCAL dbf_file := '' , message := '' , fields_total := 0
dbf_file := Getfile ( { {'.dbf Files','*.dbf'} } , 'Export from .dbf to .html' , 'c:\' , .f. , .t. )
USE &dbf_file alias database SHARED NEW via "DBFCDX"
fields_total := fcount()
IF (nHandle := FCREATE("c:\temp\Export.html", FC_NORMAL)) == -1
message := "File " + "c:\temp\Export.html " + "cannot be created:" + FERROR()
MsgExclamation(message,"File cannot be created" )
QUIT
ELSE
message := "<HTML><BODY><CENTER><B>"
message := message + "EXPORT FROM " + dbf_file + " TO c:\temp\Export.html"
message := message + "</B></CENTER><BR>"
FWRITE(nHandle, message)
message := "1) You can post something here...<BR>"
FWRITE(nHandle, message)
message := "2) You can post something here...<BR>"
FWRITE(nHandle, message)
message := "3) You can post something here...<BR>"
FWRITE(nHandle, message)
message := ".................................<BR><BR>"
FWRITE(nHandle, message)
FWRITE(nHandle, '<CENTER><TABLE BORDER=1>')
message := ""
FOR i := 1 to fields_total
message := message + "<TD>" + FIELDNAME(i) + "</TD>"
NEXT
message := "<TR>" + message + "</TR>"
FWRITE(nHandle, message)
message := ""
DO WHILE .NOT. EOF()
FOR i := 1 to fields_total
DO CASE
CASE valtype(database->(FIELDGET(i))) == "C"
message := message + "<TD>" + database->(FIELDGET(i)) + " </TD>"
CASE valtype(database->(FIELDGET(i))) == "N"
message := message + "<TD>" + str(database->(FIELDGET(i))) + " </TD>"
CASE valtype(database->(FIELDGET(i))) == "D"
message := message + "<TD>" + DTOC(database->(FIELDGET(i))) + " </TD>"
ENDCASE
NEXT
message := "<TR>" + message + "</TR>"
FWRITE(nHandle, message)
message := ""
database->( DBSKIP() )
ENDDO
message := "</TABLE></CENTER><BR>"
FWRITE(nHandle,message)
message := "4) You can post something here...<BR>"
FWRITE(nHandle, message)
message := "5) You can post something here...<BR>"
FWRITE(nHandle, message)
message := "6) You can post something here...<BR>"
FWRITE(nHandle, message)
message := "</BODY></HTML>"
FWRITE(nHandle,message)
FCLOSE(nHandle)
message := "EXPORT FROM " + dbf_file + " TO c:\temp\Export.html"
MSGBOX(message, 'EXPORT OK !')
QUIT
ENDIF
RETURN
Re: written report with customized content, records changes
Posted: Sat Dec 04, 2010 8:16 pm
by esgici
nguyenchiduc wrote:You also can export from .dbf to .html file and write, draw something in.
Thanks to sharing
By the way, does low-level file IO is mandatory and/or necessary
Regards
--
Esgici
Re: written report with customized content, records changes
Posted: Sun Dec 05, 2010 11:28 am
by nguyenchiduc
esgici wrote:Thanks to sharing
By the way, does low-level file IO is mandatory and/or necessary
Regards
--
Esgici
Thank you
I only illustrate the vast capabilities of HMG that we have not fully exploited.
For example:
If we know the structure of files such as Excel, Pdf, Xml... we can
import/export directly to the file .Dbf .
HMG and
Apache webserver can be applied to the Web - CGI, based on the file .dbf or queries from the database such as Oracle, MySQL, MS SQL,...