Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rewrite
Message
From
24/01/2007 02:12:44
 
 
To
23/01/2007 14:18:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01187577
Message ID:
01188518
Views:
25
hi,
thank you,it works, but still my excel sheet have numbers not time,
(FUNCTION Sec2Str(tnSeconds, llDays),not works,
how i can convert all fields exept the last field to characters type,

any way this code under it works for me, just i fetch for another simple way,
thanks alot
CLOSE all
create table newcurbilldata ( divi c(20),mac1 c(20),m1_m c(20), m1_a c(20),m1_t c(20),;
m2_m c(20), m2_a c(20),m2_t c(20),m3_m c(20), m3_a c(20),m3_t c(20),;
m4_m c(20), m4_a c(20),m4_t c(20),m5_m c(20), m5_a c(20),m5_t c(20),;
m6_m c(20), m6_a c(20),m6_t c(20),m7_m c(20), m7_a c(20),m7_t c(20),;
m8_m c(20), m8_a c(20),m8_t c(20),m9_m c(20), m9_a c(20),m9_t c(20),;
m10_m c(20), m10_a c(20),m10_t c(20),m11_m c(20), m11_a c(20),m11_t c(20),;
m12_m c(20), m12_a c(20),m12_t c(20),tot_m c(20),tot_a c(20),tot_t c(20), tot_per n(20,3))
*********
  select 1
     use curbilldata
do whil .t. .and. !eof()
******************
   m.a1=Sec2Str(m1_m)
   m.a2=Sec2Str(m2_m)
   m.a3=Sec2Str(m3_m)
   m.a4=Sec2Str(m4_m)
   m.a5=Sec2Str(m5_m)
   m.a6=Sec2Str(m6_m)
   m.a7=Sec2Str(m7_m)
   m.a8=Sec2Str(m8_m)
   m.a9=Sec2Str(m9_m)
   m.a10=Sec2Str(m10_m)
   m.a11=Sec2Str(m11_m)
   m.a12=Sec2Str(m12_m)
   ********************
   m.b1=Sec2Str(m1_a)
   m.b2=Sec2Str(m2_a)
   m.b3=Sec2Str(m3_a)
   m.b4=Sec2Str(m4_a)
   m.b5=Sec2Str(m5_a)
   m.b6=Sec2Str(m6_a)
   m.b7=Sec2Str(m7_a)
   m.b8=Sec2Str(m8_a)
   m.b9=Sec2Str(m9_a)
   m.b10=Sec2Str(m10_a)
   m.b11=Sec2Str(m11_a)
   m.b12=Sec2Str(m12_a)
   ********************
   m.c1=Sec2Str(m1_t)
   m.c2=Sec2Str(m2_t)
   m.c3=Sec2Str(m3_t)
   m.c4=Sec2Str(m4_t)
   m.c5=Sec2Str(m5_t)
   m.c6=Sec2Str(m6_t)
   m.c7=Sec2Str(m7_t)
   m.c8=Sec2Str(m8_t)
   m.c9=Sec2Str(m9_t)
   m.c10=Sec2Str(m10_t)
   m.c11=Sec2Str(m11_t)
   m.c12=Sec2Str(m12_t)
   ********************
   m.d=Sec2Str(tot_m)
   m.e=Sec2Str(tot_a)
   m.f=Sec2Str(tot_t)
   m.g=Sec2Str(tot_tot)
   m.h=tot_per
   *******************
   m.i=divi
   m.j=mac1
*********************
     select 2
USE newcurbilldata
APPEND BLANK
REPLACE m1_m WITH m.a1,m2_m WITH m.a2,m3_m WITH m.a3,m4_m WITH m.a4,m5_m WITH m.a5,;
m6_m WITH m.a6,m7_m WITH m.a7,m8_m WITH m.a8,m9_m WITH m.a9,m10_m WITH m.a10,m11_m WITH m.a11,;
m12_m WITH m.a12,;
m1_a WITH m.b1,m2_a WITH m.b2,m3_a WITH m.b3,m4_a WITH m.b4,m5_a WITH m.b5,m6_a WITH m.b6,;
m7_a WITH m.b7,m8_a WITH m.b8,m9_a WITH m.b9,m10_a WITH m.b10,m11_a WITH m.b11,m12_a WITH m.b12,;
m1_t WITH m.c1,m2_t WITH m.c2,m3_t WITH m.c3,m4_t WITH m.c4,m5_t WITH m.c5,m6_t WITH m.c6,;
m7_t WITH m.c7,m8_t WITH m.c8,m9_t WITH m.c9,m10_t WITH m.c10,m11_t WITH m.c11,m12_t WITH m.c12,;
tot_m with   m.d,tot_a with  m.e,tot_t with   m.f,tot_per with  m.h,divi WITH m.i,mac1 WITH m.j


    select 1
      skip

   if eof()
    exit
   endif
enddo
CLOSE ALL
**********************************************************************
USE newcurbilldata
gcDelimName = ALIAS( ) + '.xls'
gcDelimFile = PUTFILE('excel_file:', gcDelimName, 'xls')
IF EMPTY(gcDelimFile)
   CANCEL
ENDIF
COPY  TO (gcDelimFile) XL5

************************************************************************
FUNCTION Sec2Str(tnSeconds, llDays)
LOCAL lcHH, lnTm, lcMM, lcSS, lcTime
lnTm = tnSeconds
IF llDays
   lcDD = TRANSFORM(INT(lnTm / 86400), "99") + " "
   lnTm = tnSeconds % 86400
   lcHH = TRANSFORM(INT(lnTm / 3600), "@L 9999")
ELSE   
   lcDD = ""
   lcHH = TRANSFORM(INT(lnTm / 3600), "@L 99999")
ENDIF 
lnTm = lnTm % 3600
lcMM = TRANSFORM(INT(lnTm / 60), "@L 99")
lcSS = TRANSFORM(INT(lnTm % 60), "@L 99")
lcTime = lcDD + lcHH + ":" + lcMM 
*lcTime = lcDD + lcHH + ":" + lcMM + ":" + lcSS
RETURN lcTime
still my excel sheet have numbers not time,
(FUNCTION Sec2Str(tnSeconds, llDays),not works,
CLOSE all
**create cursor from a file
USE curbilldata && Open table.&& fields from 3 to 42 is numaric type

gnFieldcount = AFIELDS(gaMyArray) && Create array.
**??? gnFieldcount=43 fields
*** CURSOR newcurbilldata &&&fields from 3 to 42 must be characters type
clos data
CREATE CURSOR newcurbilldata FROM ARRAY gaMyArray
sele 0
use curbilldata
scan
scatter memvar
sele newcurbilldata
append blank
gather  memvar
sele curbilldata
endscan
sele newcurbilldata
browse

CLOSE ALL
use newcurbilldata
**********************************************************************
gcDelimName = ALIAS( ) + '.xls'
gcDelimFile = PUTFILE('excel_file:', gcDelimName, 'xls')
IF EMPTY(gcDelimFile)
   CANCEL
ENDIF
COPY  TO (gcDelimFile) XL5


**************************************************************************
FUNCTION Sec2Str(tnSeconds, llDays)

LOCAL lcHH, lnTm, lcMM, lcSS, lcTime
lnTm = tnSeconds
IF llDays
   lcDD = TRANSFORM(INT(lnTm / 86400), "99") + " "
   lnTm = tnSeconds % 86400
   lcHH = TRANSFORM(INT(lnTm / 3600), "@L 9999")
ELSE   
   lcDD = ""
   lcHH = TRANSFORM(INT(lnTm / 3600), "@L 99999")
ENDIF 
lnTm = lnTm % 3600
lcMM = TRANSFORM(INT(lnTm / 60), "@L 99")
lcSS = TRANSFORM(INT(lnTm % 60), "@L 99")
lcTime = lcDD + lcHH + ":" + lcMM 
*lcTime = lcDD + lcHH + ":" + lcMM + ":" + lcSS
RETURN lcTime
thanks

>Try
>CLOSE all
>**create cursor from a file
>USE curbilldata && Open table.
>
>gnFieldcount = AFIELDS(gaMyArray) && Create array.
>clos data
>CREATE CURSOR newcurbilldata FROM ARRAY gaMyArray
>sele 0
>use curbilldata
>scan
>scatter memvar
>sele newcurbilldata
>append blank
>gather from memvar
>sele curbilldata
>endscan
>sele newcurbilldata
>browse
Previous
Reply
Map
View

Click here to load this message in the networking platform