Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hex values converted to exponents during Excel Automatio
Message
From
29/01/2004 03:54:06
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/01/2004 19:08:53
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00871210
Message ID:
00871689
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
>I have the need to send data to an Excel spreadsheet. I'm using automation to write the values out to the spreadsheet but one of the rows of data is a four digit hexadecimal number which is sometimes interpreted by Excel as a exponential expression.
>
>I've tried to find a way to Excel to format that column/range of cells as text but either the answer is hidden well or the lack of sleep has caused me to miss the answer in the Excel help file and Office Automation with Visual Foxpro book by Tamar Granor and Della Martin.
>
>The current, mostly working bit of code...
>
>
>      .Columns[1].value  = lnPartCnt
>      .Columns[2].NumberFormat = '00##'
>      .Columns[2].value  = CastHist.SerialNo
>      .Columns[3].value  = CastHist.MastHeat
>
>
>Examples of the hex data that is converted...
>2E63
>30E8
>30E7
>
>
>Help? :(

Format the column as text. ie:
Local Array arrVals[3]
arrVals[1] = '2E63'
arrVals[2] = '30E8'
arrVals[3] = '30E7'
oExcel = Createobject('excel.application')
With oExcel
  .WorkBooks.Add
  With .ActiveWorkBook.ActiveSheet
    .Range('B:B').Numberformat = '@'
    For ix=1 To 3
      With .Range('A'+Transform(m.ix)+':C'+Transform(m.ix))
        .Columns[1].Value = m.ix
        .Columns[2].Value = m.arrVals[m.ix]
        .Columns[3].Value = m.arrVals[m.ix]
      Endwith
    Endfor
  Endwith
  .Visible = .T.
Endwith
PS: Setting excel values cell by cell should be a killer. HAve you ever thought of copying data to clipboard and paste, or copy to csv,fox2x dbf,text and get from excel.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform