Konu: Excelde Hücre Formatı
Excel dosyasındaki bir hücrenin formatını kodla program için den nasıl değiştirebilirim? ( C15 hücresinin formatı sayı ve "9999.99" şeklinde olsun)
Giriş yapmadınız. Lütfen giriş yapın yada kayıt olun.
fox4um » Kodlama ve Komutlar » Excelde Hücre Formatı
Excel dosyasındaki bir hücrenin formatını kodla program için den nasıl değiştirebilirim? ( C15 hücresinin formatı sayı ve "9999.99" şeklinde olsun)
oExcel.ActiveWorkbook.ActiveSheet.Range('C15').NumberFormat = "0.00"
Bildigim kadariyla VFP'deki tarzda format yok ( maximum 9999.99 degil).
Çetin bey çok teşekkürler.
Ancak bir sorum daha olacak.
ben formatı "000.000" şeklinde yapmıştım
12.3457 olan sayı
0012.3457 şeklinde oluyor. soldaki sıfırların değeri yok.
soldaki sıfırları nasıl yok edebiliriz.
Çetin bey tekrar teşekkürler
"#####.0000" şeklinde kullandım. Eğer kuruş kısmını da # yaparsam standart olmuyor. yani kuruş bölümü 4 karakter olmuyor. Kuruş bölümünün 4, Lira bölümünün değişken olması için bunu uyguladım.
Bir hücreye kenarlık çizme veya iptal etmeyi nasıl yapabilirim?
If Type("oExcel")<>"O"
Public oexcel
oexcel = Createobject('Excel.Application')
oexcel.Workbooks.Add
oexcel.Application.DisplayAlerts = .F.
oexcel.Application.DisplayAlerts = .T.
oexcel.Visible = .T.
Else
oexcel.Sheets.Add
Endif
With oexcel.Cells.Font
.Name = "Arial"
.Size = 10
.Bold = .T.
Endwith
oexcel.activesheet.Name = "General"
oexcel.Cells( 1, 2).Select
With oexcel.Selection.BorderS(7)
.LineStyle = 1
.Weight = 1 && xlHairline
.ColorIndex = -4105
Endwith
With oexcel.Selection.BorderS(8)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
Endwith
With oexcel.Selection.BorderS(9)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
Endwith
With oexcel.Selection.BorderS(10)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
Endwith
With oexcel.Selection.BorderS(11)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
Endwith
With oexcel.Selection.BorderS(12)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
Endwith
#include xlconstants.h
Local oExcel
oExcel = Createobject("Excel.Application")
With oExcel
.WorkBooks.Add
.Visible = .T.
VFP2Excel(_samples+'data\testdata.dbc',;
'select'+;
' CAST(TRIM(Company) as varchar(50)) as Company,'+;
' CAST(TRIM(Contact) as varchar(50)) as Contact,'+;
' MaxOrdAmt'+;
' from customer',;
.ActiveWorkBook.ActiveSheet.Range('A1'))
With .ActiveWorkBook.ActiveSheet
.UsedRange.Columns.AutoFit() && kolonlari otomatik genislet
* Sola, saga, ortaya hizala
.UsedRange.Columns(1).HorizontalAlignment = xlLeft
.UsedRange.Columns(2).HorizontalAlignment = xlCenter
.UsedRange.Columns(3).HorizontalAlignment = xlRight
* Tum satirlara ince cizgi
With .UsedRange.Rows.BorderS
.Weight = xlThin
.LineStyle = xlContinuous
Endwith
* Ilk satira cift mavi cizgi
With .UsedRange.Rows(1).BorderS
.LineStyle = xlDouble
.ColorIndex = 5
Endwith
* Besinci-yedinci satirlar cizgisiz
With .Range( .UsedRange.Rows(5), .UsedRange.Rows(7) ).BorderS
.LineStyle = xlNone
Endwith
Endwith
Endwith
Function VFP2Excel
Lparameters tcDataSource, tcSQL, toRange
Local loConn As AdoDB.Connection, ;
loRS As AdoDB.Recordset,;
ix
loConn = Createobject("Adodb.connection")
loConn.ConnectionString = "Provider=VFPOLEDB;Data Source="+m.tcDataSource
loConn.Open()
loRS = loConn.Execute(m.tcSQL)
For ix=1 To loRS.Fields.Count
toRange.Offset(0,m.ix-1).Value = Proper(loRS.Fields(m.ix-1).Name)
toRange.Offset(0,m.ix-1).Font.Bold = .T.
Endfor
toRange.Offset(1,0).CopyFromRecordSet( loRS )
loRS.Close
loConn.Close
Endfunc
Cevaplarınız için teşekkürler.
.Range("A1:F1").Borders.LineStyle =1
şeklinde de oluyormuş. Bu benim için daha kullanışlı.
fox4um » Kodlama ve Komutlar » Excelde Hücre Formatı