Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Formating cell content in XL
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Formating cell content in XL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Divers
Thread ID:
01099239
Message ID:
01099239
Vues:
79
Hi Cetin:
Please forgive my direct approach: You have been most helpful in the past in regard to OLEAutomation of Excel so it is possible you may immediately know the answer to this question. If not, perhaps someone else may know the answer.

How do you code to align cell content to be 'center'?
I have the following code which works perfectly for my purposes except I need the data to be centered in the target cells:
* get the attributes of the fields in this cursor  ~ cursor produced via SQL select on data source no problem
nNumFields = AFIELDS(aMyProds, 'MyProds')

* move selected data into XL
oleApp = CREATEOBJECT("Excel.Application")        && Start Excel.
 
OleApp.Workbooks.Add                              && Create a workbook.

* now put this data into the XL sheet
FOR i = 1 TO nNumFields STEP 1
      WITH OleApp.Cells(1, i) 
         .columnwidth = IIF(aMyProds(i, 3) < LEN(aMyProds(i, 1)), (LEN(aMyProds(i, 1))) + 4, aMyProds(i, 3))
     WITH .Font
            .Size = 10
            .Bold = .T.
            .ColorIndex = 4
      ENDWITH
      .Background = 0
      .Value = aMyProds(i, 1)                      && Set a cell's value.

***  I need to add the cell content alignment code somewhere in here? ****** everything else works fine
      
      ENDWITH
   
ENDFOR

* make workbook visible
OleApp.Visible=.T.                                 && Display Excel.

etc ...
TIA. /psb
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform