Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Format Excel columns
Message
De
06/03/2003 02:42:10
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/03/2003 15:17:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00761748
Message ID:
00762014
Vues:
13
This message has been marked as a message which has helped to the initial question of the thread.
>Hello all
>
>I want to draw a grey fill column B2 and i want to set the WIDTH Of the column B to be 60 how to set it

Akhan,
I assume 60 for width is in pixels. There are 2 properties used in column width, WIDTH and COLUMNWIDTH. One is in chars and the other is in points. You could convert to points but you can't set using columnwidth (I don't know why, according to docs it shouldn't be readonly but it fails). To use other you should get the width in chars.
For color setting you could also use .Color = rgb(). However Excel has a color palette and it's a little probability the color you choose would match. It'd pick nearest from its palette. So use ColorIndex instead.
Local lnPixels,lnOneChar
lnPixels = 60
oExcel = Createobject('Excel.Application')
With oExcel
  .Workbooks.Add
  With .ActiveSheet
    With .Range('A1').Font
      lnOneChar = Txtwidth('0',.Name,.Size) * Fontmetric(6,.Name,.Size)
    Endwith
    With .Range('B:B')
      .ColumnWidth = Int(lnPixels/lnOneChar)
      .Interior.ColorIndex = 15
    Endwith
  Endwith
  .Visible = .T.
Endwith
PS:It's almost impossible to get exact pixels for columnwidth. For rowheight you can.
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
Répondre
Fil
Voir

Click here to load this message in the networking platform