Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Losing decimals when filling spreadsheet
Message
 
À
06/06/2002 07:48:59
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00664829
Message ID:
00665774
Vues:
29
>>Found the problem. To me, it's a VFP bug, but it might be by design.
>>
>>When using OLE automation to fill a spreadsheet, if the variable is typed "Currency" VFP rounds to 2 decimal places before sending to Excel. You can't even fool VFP by reading the value into memory and then sending to Excel because VFP keeps the variable typed as currency.
>>
>>If you create a temp sql cursor from a table with currency values, the values in the temp cursor are typed as currency. I had to define some variables as numeric (99.9999 AS yPremium) and created another variable as currency (yPremium AS premium) used the READWRITE keyword to make a cursor I could write to and scanned the cursor replacing the yPreimum with Premium. Then when I used the yPremium variable in the statement it was typed as numeric.
>>
>>I guess I could have changed the value like this:
>>
>>lnValue = VAL(STR(yPremium,7,4)) to change it also, but thought of it later.
>>
>>So if you need to export more than 2 decimals to Excel make sure you don't store them as currency.
>
>You can convert to numeric with mton(), before converting to Excel.
>
>HTH, Hilmar.

Thanks, I missed that function in Help.
Don Tanner
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform