To All
Now that I have the code running .. I am getting justification problems with charactor fields that contain alpha and numeric information ..
Example .. in the reg_no column I have two rows :
reg_no
2306753
20A118
For some reason .. the alpha numeric get left justified .. which causes our SQL loader to fail .. any way to make sure all the contents of the column get left justified ??
Thanks
Rick Lipkin
SC Dept of Health, USA
Code:
// dbf to xls conversion
LOCAL oExcel, oSheet
LOCAL nRow, cFILE,aDIR,mSTART,cDEFA
clear
REQUEST DBFCDX
rddsetdefault( "DBFCDX" )
setmode( 25,80 )
//-- get timestamp on .exe //
cFILE := HB_ARGV(0)
aDIR := DIRECTORY( cFILE )
// where .exe started from is default directory //
mSTART := RAT( "\", cFILE )
cDEFA := SUBSTR(cFILE,1,mSTART-1)
aDIR := NIL
SET DEFA to ( cDEFA )
oExcel := CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Add()
oSheet := oExcel:ActiveSheet
select 1
USE cert via "DBFCDX" shared
go top
oSheet:Cells( 1, 1 ):value := "REG_NO"
oSheet:Cells( 1, 2 ):value := "NAME"
oSheet:Cells( 1, 3 ):value := "ADDR1"
oSheet:Cells( 1, 4 ):value := "ADDR2"
oSheet:Cells( 1, 5 ):value := "ADDR3"
oSheet:Cells( 1, 6 ):value := "CITY"
oSheet:Cells( 1, 7 ):value := "STATE"
oSheet:Cells( 1, 8 ):value := "ZIP"
oSheet:Cells( 1, 9 ):value := "ZIP4"
oSheet:Cells( 1, 10):value := "SCHD"
oSheet:Cells( 1, 11):value := "INIT_DATE"
oSheet:Cells( 1, 12):value := "EXPIR_DATE"
nRow := 2
Do WHILE !EOF()
@ 10,10 say str(Nrow)+" "+cert->name
if deleted()
select cert
skip
loop
endif
oSheet:Cells( nRow, 1 ):Value := cert->reg_no
oSheet:Cells( nRow, 2 ):Value := cert->name
oSheet:Cells( nRow, 3 ):Value := cert->addr1
oSheet:Cells( nRow, 4 ):Value := cert->addr2
oSheet:Cells( nRow, 5 ):Value := cert->addr3
oSheet:Cells( nRow, 6 ):Value := cert->city
oSheet:Cells( nRow, 7 ):Value := cert->state
oSheet:Cells( nRow, 8 ):Value := cert->zip
oSheet:Cells( nRow, 9 ):Value := cert->zip4
oSheet:Cells( nRow, 10 ):Value := cert->schd
oSheet:Cells( nRow, 11 ):Value := if(EMPTY(cert->expir_date), "00/00/00", cert->expir_date)
oSheet:Cells( nRow, 12 ):Value := if(EMPTY(cert->init_date), "00/00/00", cert->init_date)
nRow++
@ 10,10 say str(Nrow)+" "+cert->name
select cert
SKIP
ENDDO
oSheet:Columns( "A:L" ):AutoFit()
ferase( cDEFA+"\CERT.XLS" )
oSheet:SaveAs( cDEFA+"\CERT.XLS" )
oExcel:Quit()
close databases
quit