Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hex values converted to exponents during Excel Automatio
Message
De
29/01/2004 03:54:06
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
27/01/2004 19:08:53
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00871210
Message ID:
00871689
Vues:
15
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform