Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Phillip Davies
  Where is Phillip Davies?
 TRURO
 United Kingdom
 Phillip Davies
 Tags
Subject: RE: XLS
Thread ID: 373355 Message ID: 373393 # Views: 43 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Projects and Design
Date: Thursday, March 21, 2013 10:17:07 PM         
   


> Hi,
>
> It's a standard DBF Table with 1500 records containing Account Number, Contact Name, Quantity, Product Ref
>
> Like
>
> ACC12345 |Mr M Smith |32 |PC2354 |
> ACC62584 |Mr J Jones |54 |PC9585 |
> Etc
>
>
>
> I want to create XLSX 4 rows, 1500 columns
>
> Mr M Smith |Mr J Jones | --->>>>>>> Etc
> ACC12345 |ACC62584 |
> PC2354 |PC9585 |
> 32 |54 |
>
> That's it ( | are the columns)
>
> Phillip

Oh than that is very easy and can be done in multiple ways. One of the easiest is to get the data into an array, tranpose it on VFP side and put transposed array values into excel. ie:


Local Array laData[1]
Select accountNo, accName, age, dummy From crsSampleData Into Array laData

Local ix, jx
Dimension aMyData[ALEN(laData,2), ALEN(laData,1)]
For ix = 1 To Alen(laData,1)
  For jx = 1 To Alen(laData,2)
    aMyData[m.jx,m.ix] = laData[m.ix, m.jx]
  Endfor
Endfor

Local oExcel, loRange
oExcel = Createobject('excel.application')
With oExcel
  .Workbooks.Add
  .Visible = .T.
  With .ActiveWorkbook.ActiveSheet
    .Range( .Cells(1,1), .Cells(Alen(aMyData,1),Alen(aMyData,2))).Value = getArrayRef('aMyData')
  Endwith
Endwith

Procedure getArrayRef(tcArrayName)
  Return @&tcArrayName
Endproc

Procedure CreateSampleData
  Create Cursor crsSampleData (accountNo c(10), accName c(15), age i, dummy c(6))
  Local ix
  Rand(-1)
  For ix=1 To 1500
    Insert Into crsSampleData ;
      (accountNo, accName, age, dummy) ;
      VALUES ;
      (Textmerge('ACC<< m.ix >>'), ;
      TEXTMERGE('Mr #<< m.ix >>'), ;
      RAND()*60+10, ;
      TEXTMERGE('PC<< m.ix >>'))
  Endfor
  Brow
Endproc




Cetin Basoz

.Net has got better.Think about moving - check my blog:
My Blog


MongoDb Certified Developer
MongoDb Certified DBA


Support Wikipedia

ENTIRE THREAD

XLS Posted by Phillip Davies @ 3/21/2013 2:26:27 PM
RE: XLS Posted by Cetin Basoz @ 3/21/2013 3:01:15 PM
RE: XLS Posted by Phillip Davies @ 3/21/2013 8:45:13 PM
RE: XLS Posted by Anders Altberg @ 3/21/2013 9:20:37 PM
RE: XLS Posted by Cetin Basoz @ 3/21/2013 10:17:07 PM
RE: XLS Posted by Phillip Davies @ 3/21/2013 11:49:04 PM