Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy VFP Array to Excel
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Copy VFP Array to Excel
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01076673
Message ID:
01076673
Vues:
500
WindowsXP, VFP7/VFP9, Excel2002.

Could anybody shed some light on this behavior of one-dimensional array (see example below)? It seems that arrays are created identical (1 and 2), but they behave differently. For array2 only the first member is copied. The result is like this:

Array1 Array2 Array3

Value 1 Value 1 Value 1
Value 2 Value 1 Value 2
Value 3 Value 1 Value 3
Value 4 Value 1 Value 4
Value 5 Value 1 Value 5
Value 6 Value 1 Value 6
Value 7 Value 1 Value 7
Value 8 Value 1 Value 8
Value 9 Value 1 Value 9
Value 10 Value 1 Value 10
....
CLOSE TABLES all
DIMENSION tmp_array2[200]    && problem with this
DIMENSION tmp_array3[200,2]

DIMENSION tmp_array1[200]

Local m.oXl_App   
  Create Cursor test (test_date C (25))  
  For m.nIndex=1 To 200  
	   Insert Into test Values ("Value "+TRANSFORM(m.nIndex))  
	   tmp_array2[m.nIndex] = "Value "+TRANSFORM(m.nIndex)
   	   tmp_array3[m.nIndex,1] = "Value "+TRANSFORM(m.nIndex)
  Endfor   
  
  Select test_date From test  Into Array tmp_array1
	
  m.oXl_App=Createobject("EXCEL.Application")  
  With m.oXl_App  
   	.Workbooks.Add()  
	.worksheets(1).Range(.cells(1,1),.cells(Alen(tmp_array1,1),1)).Value=aPasser('tmp_array1')  
    .worksheets(1).Range(.cells(,2),.cells(Alen(tmp_array2,1),2)).Value=aPasser('tmp_array2')  
	.worksheets(1).Range(.cells(,3),.cells(Alen(tmp_array3,1),3)).Value=aPasser('tmp_array3')  
   	.Application.Visible =.T.  
  Endwith  
    
....    
    
 *------------------  
  Procedure  aPasser  
 *------------------  
  Lparameters m_array  
  Return @&m_array  
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform