Invisible Sheets of Excel

Invisible Sheets of Excel

Postby Ehab Samir Aziz » Sat Sep 16, 2006 8:43 pm

I noticed after doing OLE calls in my program that after quitting my program some Excel sheets -which is not related to the sheets created from program-not appeared (The Excel bars appeared but the sheet itself is invisible).
Is something wrong with the code ?

Code: Select all  Expand view

function executexcel(oCombo1,oCombo2,oCombo3,oCombo4,oCombo5,oCombo6,oCombo7,oCombo8,oCombo9,oCombo10,v_strd,v_endd)
*--------------------------------------------------------------------------------------------------------

LOCAL cPath := "E:\programs\clipper\fwh\sitex\test.XLS"
local oExcel,oBook,oSheet
LOCAL nline:=13
LOCAL head_var:=4
LOCAL head_cons:=1

local ncol
local oDlgn
local nCounter:=1
local nStart := nCounter
local cMemo := ''
local a2_fields[12]
local a2_vars[12]
local cFilter:=""
local cValue:=""
local i:=0
local cReccount:=0
local bFilter
local to_printsj:="",to_printsk:="",to_printsl:="",to_printsm:="",;
to_printsn:="",to_printso:="",to_printsp:="",to_printsq:="",to_printsr:=""
local psg:=0
local osg:=0


   REQUEST ADS
   rddRegister( "ADS", 1 )
   rddsetdefault( "ADS" )
   AdsSetDeleted(.T.)
   SET SERVER LOCAL
   SET FILETYPE TO CDX


DEFINE DIALOG oDlgn TITLE "Executing Filtering Creteria" ;
From 1, 2 TO 500, 700 PIXEL

oExcel=TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Add()
OSheet = oExcel:Get( "ActiveSheet" )


    oSheet:Cells( 1, 3 ):Value = "Meter Reader Report From :"
    oSheet:Cells( 1, 6 ):Value = dtoc(v_strd)
    oSheet:Cells( 1, 7 ):Value = "To :"
    oSheet:Cells( 1, 8 ):Value = dtoc(v_endd)


    oSheet:Cells( 2, head_cons ):Value = "Customer Name        :"
    oSheet:Cells( 2, head_var ):Value = oCombo1

    oSheet:Cells( 3, head_cons ):Value = "Account Number       :"
    oSheet:Cells( 3, head_var ):Value = oCombo2


    oSheet:Cells( 4, head_cons ):Value = "Contract name        :"
    oSheet:Cells( 4, head_var ):Value = oCombo3

    oSheet:Cells( 5, head_cons ):Value = "Machine Type         :"
    oSheet:Cells( 5, head_var ):Value = oCombo4

    oSheet:Cells( 6, head_cons ):Value = "Machine Model        :"
    oSheet:Cells( 6, head_var ):Value = oCombo5

    oSheet:Cells( 7, head_cons ):Value = "Machine Serial       :"
    oSheet:Cells( 7, head_var ):Value = oCombo6

    oSheet:Cells( 8, head_cons ):Value = "Machine Branch       :"
    oSheet:Cells( 8, head_var ):Value = oCombo7

    oSheet:Cells( 9, head_cons ):Value = "Machine Responsibile :"
    oSheet:Cells( 9, head_var ):Value = oCombo8

    oSheet:Cells( 10, head_cons ):Value = "Machine Department   :"
    oSheet:Cells( 10, head_var ):Value = oCombo9

    oSheet:Cells( 11, head_cons ):Value = "Machine Location    :"
    oSheet:Cells( 11, head_var ):Value = oCombo10

    oSheet:Cells( 12, 1 ):Value = "Serial"
    oSheet:Cells( 12, 2 ):Value = "Customer Name"
    oSheet:Cells( 12, 3 ):Value = "Contract Name"
    oSheet:Cells( 12, 4 ):Value = "Machine Branch"
    oSheet:Cells( 12, 5 ):Value = "Machine Type"
    oSheet:Cells( 12, 6 ):Value = "Machine Model"
    oSheet:Cells( 12, 7 ):Value = "Machine Serial"
    oSheet:Cells( 12, 8 ):Value = "Opening"
    oSheet:Cells( 12, 9 ):Value = "Closing"
    oSheet:Cells( 12, 10 ):Value = "Prints"
    oSheet:Cells( 12, 11 ):Value = "Waste"
    oSheet:Cells( 12, 12 ):Value = "COLOR"
    oSheet:Cells( 12, 13 ):Value = "BLACK"
    oSheet:Cells( 12, 14 ):Value = "A3"
    oSheet:Cells( 12, 15 ):Value = "DUPLEX"
    oSheet:Cells( 12, 16 ):Value = "OSG"
    oSheet:Cells( 12, 17 ):Value = "PSG"
    oSheet:Cells( 12, 18 ):Value = "Charge"




a2_fields[1]:="mete->Me_CU_name"
a2_fields[2]:="mete->Me_CU_ACCt"
a2_fields[3]:="mete->Me_CT_CTNA"
a2_fields[4]:="mete->Me_mc_type"
a2_fields[5]:="mete->Me_mc_modl"
a2_fields[6]:="mete->Me_mc_serl"
a2_fields[7]:="mete->Me_mc_brn"
a2_fields[8]:="mete->Me_mc_mere"
a2_fields[9]:="mete->Me_mc_dep"
a2_fields[10]:="mete->Me_mc_loc"
a2_fields[11]:="mete->Me_date"
a2_fields[12]:="mete->Me_date"

a2_vars[1]:=oCombo1
a2_vars[2]:=oCombo2
a2_vars[3]:=oCombo3
a2_vars[4]:=oCombo4
a2_vars[5]:=oCombo5
a2_vars[6]:=oCombo6
a2_vars[7]:=oCombo7
a2_vars[8]:=oCombo8
a2_vars[9]:=oCombo9
a2_vars[10]:=oCombo10
a2_vars[11]:=v_strd
a2_vars[12]:=v_endd


For i := 1 to 12

     IF Empty(a2_Vars[i])     && Don't process empty variables
         LOOP
     ENDIF

     DO CASE            && Create char value
         CASE VALTYPE(a2_vars[i]) == "D" .AND. i==11
                 cValue:= 'DTOS(' + a2_Fields[i] + ') >= "' + DTOS(a2_Vars[i]) + '"'
         CASE VALTYPE(a2_vars[i]) == "D" .AND. i==12
                 cValue := 'DTOS(' + a2_Fields[i] + ') <= "' + DTOS(a2_Vars[i]) + '"'
         CASE VALTYPE(a2_vars[i]) == "N"
             cValue := 'STR(' + a2_Fields[i] + ') == "' + STR(a2_vars[i]) + '"'       && or
         CASE VALTYPE(a2_vars[i]) == "C"
             cValue :="upper("+ a2_Fields[i]+")" + '=="' + upper(a2_Vars[i]) + '"'
     ENDCASE
     IF Empty(cFilter)     && this is the first element
         cFilter :=  cValue
     ELSE
         cFilter += " .AND. " + cValue
     ENDIF
NEXT


use mete new
index on mete->me_mc_brn+mete->me_mc_type+mete->me_mc_MODL to mete3

cReccount:= reccount()
mete->(dbgotop())
/*
INDEX ON upper(mete->me_mc_brn) TO temp FOR &(cFilter) unique
mete->(dbgotop())*/

bFilter = "{||("+cFilter+")}"
cFilter = "("+cFilter+")"

DBSETFILTER(&bFilter,cFilter)

mete->(dbgotop())






 



DO WHILE !(4)->(EOF())
if rtrim((4)->me_mc_type) = "Fax     "

    oSheet:Cells( nLine, 1 ):Value = nLine-12
    oSheet:Cells( nLine, 2 ):Value = (4)->me_cu_name
    oSheet:Cells( nLine, 3 ):Value = (4)->me_ct_ctna
    oSheet:Cells( nLine, 4 ):Value = (4)->me_mc_brn
    oSheet:Cells( nLine, 5 ):Value = (4)->me_mc_type
    oSheet:Cells( nLine, 6 ):Value = (4)->me_mc_modl
    oSheet:Cells( nLine, 7 ):Value = (4)->me_mc_serl
    oSheet:Cells( nLine, 8 ):Value = (4)->open_meter
    oSheet:Cells( nLine, 9 ):Value = (4)->cls_meter
    oSheet:Cells( nLine, 10 ):Value = 0
    oSheet:Cells( nLine, 11 ):Value = 0
    oSheet:Cells( nLine, 12 ):Value = 0
    oSheet:Cells( nLine, 13 ):Value = 0
    oSheet:Cells( nLine, 14 ):Value = 0
    oSheet:Cells( nLine, 15 ):Value = 0
    oSheet:Cells( nLine, 16 ):Value = 0
    oSheet:Cells( nLine, 17 ):Value = 0
    oSheet:Cells( nLine, 18 ):Value = 0
    else
    oSheet:Cells( nLine, 1 ):Value = nLine-12
    oSheet:Cells( nLine, 2 ):Value = (4)->me_cu_name
    oSheet:Cells( nLine, 3 ):Value = (4)->me_ct_ctna
    oSheet:Cells( nLine, 4 ):Value = (4)->me_mc_brn
    oSheet:Cells( nLine, 5 ):Value = (4)->me_mc_type
    oSheet:Cells( nLine, 6 ):Value = (4)->me_mc_modl
    oSheet:Cells( nLine, 7 ):Value = (4)->me_mc_serl
    oSheet:Cells( nLine, 8 ):Value = (4)->open_meter
    oSheet:Cells( nLine, 9 ):Value = (4)->cls_meter
    oSheet:Cells( nLine, 10 ):Value = (4)->prints
    oSheet:Cells( nLine, 11 ):Value = (4)->waste
    oSheet:Cells( nLine, 12 ):Value = (4)->COLOR
    oSheet:Cells( nLine, 13 ):Value = (4)->BLACK
    oSheet:Cells( nLine, 14 ):Value = (4)->A3
    oSheet:Cells( nLine, 15 ):Value = (4)->DUPLEX
    oSheet:Cells( nLine, 16 ):Value = (4)->copy
    oSheet:Cells( nLine, 17 ):Value = (4)->print
    oSheet:Cells( nLine, 18 ):Value = (4)->charge
    endif

Msgwait("  Filtering Database  ","Please wait",msgrun("Machine No. : "+alltrim(str(nLine-12))+"      Processing record No  :"+ str(recno())+"  /  "+str(cReccount)))
(4)->(DBSKIP(1))
nLine:=nLine+1
ENDDO

oSheet:Cells(nLine,9):Select()
oSheet:Cells:Font:Name:="Arial"
oSheet:Cells:Font:Size:=10
oSheet:Cells:Font:Bold:=.t.
oSheet:Columns(9):AutoFit()

to_printsj:="j"+alltrim(str(nLine-1))
to_printsj:="=SUM(J13:"+to_printsj+")"


to_printsk:="k"+alltrim(str(nLine-1))
to_printsk:="=SUM(k13:"+to_printsk+")"

to_printsl:="l"+alltrim(str(nLine-1))
to_printsl:="=SUM(l13:"+to_printsl+")"

to_printsm:="m"+alltrim(str(nLine-1))
to_printsm:="=SUM(m13:"+to_printsm+")"

to_printsn:="n"+alltrim(str(nLine-1))
to_printsn:="=SUM(n13:"+to_printsn+")"

to_printso:="o"+alltrim(str(nLine-1))
to_printso:="=SUM(o13:"+to_printso+")"

to_printsp:="p"+alltrim(str(nLine-1))
to_printsp:="=SUM(p13:"+to_printsp+")"

to_printsq:="q"+alltrim(str(nLine-1))
to_printsq:="=SUM(q13:"+to_printsq+")"


to_printsr:="r"+alltrim(str(nLine-1))
to_printsr:="=SUM(r13:"+to_printsr+")"





*? to_printsj

oSheet:Cells( nLine+1, 10 ):Value = (to_printsj)


oSheet:Cells( nLine+1, 11 ):Value = to_printsk
oSheet:Cells( nLine+1, 12 ):Value = to_printsl
oSheet:Cells( nLine+1, 13 ):Value = to_printsm
oSheet:Cells( nLine+1, 14 ):Value = to_printsn
oSheet:Cells( nLine+1, 15 ):Value = to_printso
oSheet:Cells( nLine+1, 16 ):Value = to_printsp
oSheet:Cells( nLine+1, 17 ):Value = to_printsq
oSheet:Cells( nLine+1, 18 ):Value = to_printsr


   ACTIVATE DIALOG oDlgn CENTERED NOWAIT
   oDlgn:end()

    oExcel:Visible = .T.
    oExcel:quit()


RETURN NIL
Ehab Samir Aziz
 
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Re: Invisible Sheets of Excel

Postby Enrico Maria Giordano » Sun Sep 17, 2006 8:29 am

I can't see anything wrong in your code.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Ehab Samir Aziz » Sun Sep 17, 2006 9:14 pm

Mat be lack of memory in some PCs I work in ? It sometimes happened with peolpe that their PCs exhaused with start-up program. With my PC I do not face that case never ..
Ehab Samir Aziz
 
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Postby Enrico Maria Giordano » Sun Sep 17, 2006 9:18 pm

It maybe.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google Feedfetcher and 63 guests