Page 1 of 1

Please, help with DC_WorkArea2Excel() application

Posted: Fri Sep 28, 2012 8:31 pm
by Eugene Lutsenko
The program for some reason provided below normally converts some databases in xls, and on others gives a mistake. On test examples from c:\exp19\Samples\EXCEL\ все работает отлично. Couldn't help to understand what is the matter? At me there was such impression. that I create for work any not such databases as it is necessary.

Code: Select all

/*
This test program will export a Work Area to an Excel
Spread-Sheet.
*/
#INCLUDE "dcdialog.CH"
#INCLUDE "fileio.CH"
#pragma library( "XPPRT1.LIB" )
#pragma library( "dclip1.lib" )
#pragma library( "dclip2.lib" )
#pragma library( "dclipx.lib" )
#pragma library( "xbtbase1.lib" )
#pragma library( "xbtbase2.lib" )

FUNCTION Main()

LOCAL oScrn, nError, nHandle

DC_LoadRdds()

N_dbf = ADIR("*.DBF")
PRIVATE F_name_dbf[N_dbf]
ADIR("*.DBF",F_name_dbf)    // Информация о DBF-файлах
ASORT(F_name_dbf)

FOR f=1 TO LEN(F_name_dbf)

    M_FName = SUBSTR(F_name_dbf[f],1,AT(".",F_name_dbf[f])-1)

    CLOSE ALL
    USE (M_FName) EXCLUSIVE NEW VIA 'DBFCDX'
*    USE (M_FName) EXCLUSIVE NEW VIA 'DBFNTX'

    aFields := {}
    FOR j=1 TO FCOUNT()
*        IF FIELDDECI(j) = 0
           AADD(aFields, FIELDNAME(j))
*        ENDIF
    NEXT

    DC_WorkArea2Excel( DC_CurPath() + '\'+M_FName+'.XLS',,,,aFields )
 
*    DC_SpawnUrl( DC_CurPath() + '\'+M_FName+'.XLS' )
 
NEXT

DCMSGBOX 'Done!'
 
RETURN nil
* ---------------
PROC appsys ; RETURN

Re: Please, help with DC_WorkArea2Excel() application

Posted: Sat Sep 29, 2012 10:57 am
by Auge_Ohr
hi,

as i can say Function DC_WorkArea2Excel() works ... it is your Data.

if your DBF is OEM Format you have to use ConvToAnsiCP() while Windows OLE work with ANSI.
i recommend to transfer your DBF into ARRAY() with ConvToAnsiCP() and than use DC_Array2Excel()