Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel column width
Message
De
24/12/2001 07:23:01
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/12/2001 11:25:46
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00597816
Message ID:
00597904
Vues:
15
>Excel shows column width when we are resizing column. Excel uses units and pixels to show width. when I use Automation width property shows something else (I think). So a column 80 pixels width has width property equal 48. Is ther a way to find out pixels?
>
>Thanks Mark

Mark,
For column width there are 2 units and methods. If you use ColumnWidth then width is expressed in characters (normal style - '0'), if you use Width then unit is points. Use columnwidth to set (at least I couldn't do it with width directly) :
oExcel= createobject('Excel.Application')
oExcel.Workbooks.Add
With oExcel
  .visible = .t.
  With .Activeworkbook.ActiveSheet.Columns(1)
    lcFont = .Font.Name
    lnSize = .Font.Size
    lnWidthInChars = .Columnwidth
    lnWidthInPoints = .Width
    lnWidthInPixels = lnWidthInPoints*fontmetric(19,lcFont,lnSize)/72 && 72 points = one inch
    ? 'On entry'
    ? 'Width in chars  :',lnWidthInChars
    ? 'Width in points :',lnWidthInPoints
    ? 'Width in pixels :',lnWidthInPixels

* Set to 120 pixels
    .ColumnWidth = 120/(fontmetric(6,lcFont,lnSize)*txtwidth('0',lcFont,lnSize))
    lnWidthInChars = .Columnwidth
    lnWidthInPoints = .Width
    lnWidthInPixels = lnWidthInPoints*fontmetric(19,lcFont,lnSize)/72 && 72 points = one inch
    ? 'After setting to 120 pixels'
    ? 'Width in chars  :',lnWidthInChars
    ? 'Width in points :',lnWidthInPoints
    ? 'Width in pixels :',lnWidthInPixels, 'Should be higher than 120'

* Set to 10 chars
    .ColumnWidth = 10
    lnWidthInChars = .Columnwidth
    lnWidthInPoints = .Width
    lnWidthInPixels = lnWidthInPoints*fontmetric(19,lcFont,lnSize)/72 && 72 points = one inch
    ? 'After setting to 10 chars'
    ? 'Width in chars  :',lnWidthInChars
    ? 'Width in points :',lnWidthInPoints
    ? 'Width in pixels :',lnWidthInPixels

  Endwith
Endwith
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