Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel automation and cell formatting
Message
De
23/08/2011 13:52:38
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
23/08/2011 13:46:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01521605
Message ID:
01521622
Vues:
108
This message has been marked as the solution to the initial question of the thread.
>>>Hi All,
>>>
>>>I am using Excel automation to populate some cells with data. How can I tell Excel to format a cell as character before sending through the data?
>>>
>>>Thanks
>>
>>Hi. What Sergey states is what I usually do, too. Another alternative is to FIRST change the cell format to Text, THEN insert the value.
>
>OK, how do I change the cell format to text first ?

In Excel, the shortcut to access cell format is Ctrl-1. From the tab "Number", choose "Text".

The macro recorder shows:
Selection.NumberFormat = "@"
So that would probably translate to something like:
oSheet.Cells(nrow, ncol).NumberFormat = "@"
or for a larger range:
oSheet.Range(oSheet.Cells(1,1), oSheet.Cells(100,1)).NumberFormat = "@"
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform