Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Losing decimals when filling spreadsheet
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00664829
Message ID:
00666124
Views:
23
I solved it this way. First COPY TO myFile XLS and then open myFile using VBA (oExcel) and select your way through the columns and insert the format.

With oExcel
.WorkBooks.WorkSheet.Open("myFile")
.Columns("Q:Q").Select
.Selection.ColumnWidth=8
.Selection.NumberFormat="0.000000"
endwith

>I have a program that builds an Excel worksheet with numberic values with 4 decimal places. Some of the values are losing decimals and being rounded to 2 places. I have the following code:
>
>.RANGE("F"+ALLTRIM(STR(lnRow))).VALUE = yfreight
>.RANGE("G"+ALLTRIM(STR(lnRow))).VALUE = ydiscount
>.RANGE("H"+ALLTRIM(STR(lnRow))).VALUE = ydelivered
>
>Fields in the table:
>yfreight = 0.0275
>ydiscount = 0.0012
>ydelivered = 1.2436
>
>Transfered to Excel
>F(x) = 0.03
>G(x) = 0.00
>H(x) = 1.2436
>
>I have tried to use a template with preformated columns. No luck.
>I have tried to use the following:
>.RANGE("F"+ALLTRIM(STR(lnRow))).NumberFormat = "##.####"
>No luck.
>
>I then traced the statements in Debug and yfreight was 0.0275 before and after the statement was executed but the value in Excel was 0.03 (holding your cursor over the .RANGE display's the value Excel received)
>
>ydelivered was the only numeric value transfered correctly.
>
>Has anyone had this problem?
>
>Any ideas?
>
>Thanks
>
>Don Tanner
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform