Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert to excel book
Message
De
11/09/2005 05:15:39
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Divers
Thread ID:
01048102
Message ID:
01048509
Vues:
20
hi,
thank you very much,with your code it works,
but i try as under, i see all records get it form the first excel book .
to test.xls
&&i need to insert at the new excle sheet (test),just what i select from am2.


-------------------------------------
AND IF YOU HAVE A TIME
**************************************
&& any way to insert as my select ex...
first sheet have only"ADSL 1"
second sheet have "B ISDN ")
therd sheet have "LL" , or i must do that manyaly

&& and via getdir () inside the code ,i can choice the place to save this excel book with new name.
-----------------------
this my try
CLOSE all
activate screen
SET TALK OFF
SET ECHO off
GETDIR()

thisform.text1.Value=GETFILE()
thisform.text2.value ="am"
SET DEFAULT TO e:\ut\ut
LOCAL am
am = thisform.text2.value  
CREATE TABLE &am(char1 C(10), char2 C(70),char3 C(10), char4 C(10),char5 C(10), char6 C(40),char7 C(10), char8 C(10),char9 c(10), char10 c(40),char11 C(10), char12 C(60),char13 C(50), char14 C(40),char15 C(10), char16 C(10),char17 C(10), char18 C(70),char19 C(10), char20 C(10),char21 C(10), char22 C(40),char23 C(10), char24 C(10),telno C(10), char26 C(70),char27 C(10), char28 C(10) NOCPTRANS)
APPEND FROM (thisform.text1.value)TYPE XLS

use am exclusive
 index on val(char9) tag char9
 select  sys(2015) as SortOrder,* from am ;
 order by 1 descending ;
 into cursor crsTemp nofilter

    select am
      zap
    select crsTemp

scan
 if !seek(char9,'am','char9')
    scatter fields char1 ,char3 , char7, char8, char9, char13 ,telno,  char26, char27, char28  memvar
    insert into am from memvar
 endif
endscan

Select * from am ;
  where INLIST( val(char3), 100, 201, 202, 203 );
 and ( inList( upper(allt(telno)), "ADSL 1", "B ISDN  ") or upper(left(telno,2)) = "LL" );
   into table AM2 nofilter  


CLOSE all
SELECT * from am2;
insert INTO cursor curExcel 
brow&&&& IT'S OK I SEE ONLY WHAT I NEED TO GET  FROM THIS TABLE.
loExcel = createobject( "excel.application" )
loExcel.Visible = .t.

loWorkbooks = loExcel.Workbooks
loWorkbooks.Add()
loWorkbook = loExcel.ActiveWorkbook
loSheet = loExcel.ActiveSheet

n = afields( laFields )
scan
   loRow = loSheet.Rows( recno() )
   for i = 1 to n
      loCol = loRow.Cells(,i)
      loCol.Value = evaluate( laFields[i,1] )
   endfor
endscan

loCol = .null.
loRow = .null.

loSheet = .null.
loWorkbooks = .null.

loWorkbook.Close( .t., "test.xls" )
loWorkbook = .null.

loExcel.Quit()
loExcel = .null.
THANKS.
M.QASEM

>Mohammed,
>
>>thank you very much for reply ,a dvice , site and explaine
>>
>>not much data to push .
>
>Here's some sample code.
>
>
>create cursor curExcel ( i1 i, c1 c(10), t1 t )
>
>insert into curExcel values ( 1, 'test 1', {^2005-09-10 01:23:45} )
>insert into curExcel values ( 2, 'test 2', {^2005-01-01 13:45:01} )
>insert into curExcel values ( 3, 'test 3', {^2005-12-31 23:59:59} )
>
>loExcel = createobject( "excel.application" )
>loExcel.Visible = .t.
>
>loWorkbooks = loExcel.Workbooks
>loWorkbooks.Add()
>loWorkbook = loExcel.ActiveWorkbook
>loSheet = loExcel.ActiveSheet
>
>n = afields( laFields )
>scan
>   loRow = loSheet.Rows( recno() )
>   for i = 1 to n
>      loCol = loRow.Cells(,i)
>      loCol.Value = evaluate( laFields[i,1] )
>   endfor
>endscan
>
>loCol = .null.
>loRow = .null.
>
>loSheet = .null.
>loWorkbooks = .null.
>
>loWorkbook.Close( .t., "test.xls" )
>loWorkbook = .null.
>
>loExcel.Quit()
>loExcel = .null.
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform