Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Losing decimals when filling spreadsheet
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00664829
Message ID:
00665271
Vues:
30
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.

Don
>>Hi, Don!
>>
>>Sounds like a excel formatting problem!
>>
>>Is any difference between the value which is shown in the cell and the related value which is shown in excels input line?
>
>No, the value is rounded when it goes into Excel. When I open the Excel spreadsheet the value is rounded to 2 decimal places and the cell format is General.
>
>I can't understand why it is doing that.
>
>Don
Don Tanner
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform