Konversi ke Excell

Ada kala nya kita harus mengkonversi database kita yang sudah jadi dalam artian siap
dengan kolom-kolom yang di kehendaki, ke bentuk format Excell, berikut ini cuplikan
script untuk mengkonversi file data base ke Excell, kunci nya ada pada perintah :

COPY TO ”+myexcel TYPE XL5

Simple bukan ?….

DEFINE CLASS ExcelObj AS COMMANDBUTTON
caption = ‘E\<xcel’
top = 0
left = 0
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Transfer to Excel File…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
set proc to t1
LoadRX1t = CREATEOBJECT(‘TransferObj’,5)
LoadRX1t.Show
ENDPROC
ENDDEFINE

DEFINE CLASS PrintObj AS COMMANDBUTTON
caption = ‘P\<rint’
top = 0
left = 52
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Printing to printer…’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
PUBLIC tg1
tg1 = _periode
SELECT iv_temp
SET ORDER TO 1
GO top
cPrinter = GETPRINTER()
IF !EMPTY(cPrinter)
REPORT FORM allprodx FOR saldo_ak <> 0 TO PRINTER NOCONSOLE
SET PRINTER off
ENDIF
ENDPROC

ENDDEFINE

Modul terpisah
************************************
* TRANFERS TO EXCEL *
************************************
DEFINE CLASS TransferObj AS FORM
autocenter = .T. && disable display at center of the screen
height = 180
width = 250
borderstyle = 0 && no border (unsizeable)
caption = “Transfer to Excel”
closable = .F. &&close disable ok
desktop = .T.
maxbutton = .F. && Disable Maximize Button on the upper right corner
minbutton = .F.
MDIform = .F.
showwindow = 1 && In Top Level Form
windowtype = 1 && modeless
windowstate = 0 && normal
showtips = .T. && This property will effect controls to show the tooltiptext if available
icon = ‘arppm.ico’

*** tabel begin ***
ADD OBJECT tabel_say AS LABEL;
WITH;
alignment = 0,; && Left Alignment
top = 20,;
left = 30,;
width = 105,;
height = 20,;
caption = ‘Tabel Export:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT tabel_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 20,;
left = 130,;
width = 100,;
height = 18,;
margin = 0,; && no margin
maxlength = 30,; && two digit input – 30 character field
value = ”,;
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
enabled = .f.,;
tooltiptext = ‘Tabel to Export…. ‘
*** End of tabel begin ***

*** name tabel ***
ADD OBJECT nama_say AS LABEL;
WITH;
alignment = 0,; && Left Alignment
top = 50,;
left = 30,;
width = 105,;
height = 20,;
caption = ‘To File Name:’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.

ADD OBJECT name_get AS TEXTBOX;
WITH;
alignment = 0,; && center
top = 50,;
left = 130,;
width = 100,;
height = 18,;
margin = 0,; && no margin
maxlength = 8,; && 8 digit input – 8 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Name of File Excel Tranfer…. ‘
*** End of name ***

*** dir tabel ***
ADD OBJECT dir_get AS LISTBOX;
WITH;
alignment = 0,; && center
top = 70,;
left = 30,;
width = 200,;
height = 60,;
margin = 0,; && no margin
maxlength = 100,; && 8 digit input – 8 character field
format = ‘!’,;
fontname = ‘Arial’,;
fontsize = 8,;
fontbold = .T.,;
tooltiptext = ‘Directory of File Excel Tranfer…. ‘
*** End of dir ***

*** Control Button ***
ADD OBJECT UEGB AS COMMANDGROUP;
WITH;
top = 140,;
left = 70,;
width = 400,;
height = 25,;
borderstyle = 0,;
visible=.T.
*** End of Control Button ***

* ===============
* event init / hendler
* ———————-
*** Init Event of COMMAND GROUP ***
PROC UEGB.init()
this.addobject(‘prosessbutton’,’prosesObj’)
this.addobject(‘exitbutton’,’exitObj’)
ENDPROC

PROC INIT()
LPARAMETER PL
ENDPROC

PROC dir_get.init()
SELE iv_mast1
go top
do while !eof()
this.additem(alltrim(direction))
skip
enddo
ENDPROC

PROC name_get.init()
this.value = ‘FileXLS1’
ENDPROC

PROC tabel_get.init()
this.value = ‘REPORT’
ENDPROC

ENDDEFINE

DEFINE CLASS ProsesObj AS COMMANDBUTTON
caption = ‘\<Trans’
top = 0
left = 0
width = 50
height = 25
fontname = ‘Arial’
fontsize = 8
fontbold = .T.
tooltiptext = ‘Proses Tranfers Tabel to Excel….’
mousepointer = 99
mouseicon = ‘H_point.cur’
visible = .T.

PROCEDURE click()
LOCAL ndir
LOCAL nfile
LOCAL myexcel
nfile = alltrim(this.parent.parent.name_get.value)
ndir = this.parent.parent.dir_get.displayvalue
STORE ALLTRIM(ndir+nfile+’.xls’) TO myexcel

SELECT pn as part_id,desc as keterangan,saldo_aw as saldo_awal,;
in_sjp_a1 as sj_pabrik, in_dpo_b1 as masuk_dari_depo, in_coe_e1 as cn_penjualan,;
in_adj_x1 as ajust_plus, in_tuk_t1 as tukar_plus,;
ou_coe_d1 as do_penjualan,ou_dpo_c1 as keluar_depo_gymic_out, ou_adj_x2 as ajustmen_minus,;
ou_tuk_t2 as tukar_minus, saldo_ak as saldo_akhir,in_pin_p2 as pinjaman_balik, ou_pin_p1 as dipinjam ,;
tgl1,tgl2,tgl3 as tgl_transaksi,oeno as no_order,ket as keterangan_mutasi;
FROM iv_temp
**SELECT iv_temp
COPY TO ”+myexcel TYPE XL5
messagebox(“Transfer to “+myexcel+” Completed”,48,”Pesan”)
this.parent.parent.release()
ENDPROC
ENDDEFINE

This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s