Please, help with DC_WorkArea2Excel() application

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Please, help with DC_WorkArea2Excel() application

#1 Post 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

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Please, help with DC_WorkArea2Excel() application

#2 Post 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()
greetings by OHR
Jimmy

Post Reply