Code:
(vl-load-com)
(defun c:excelislem ()
(setvar "cmdecho" 0)
(pl:excel-ac)
(vlax-put-property OEX "Visible" :vlax-true) ; EXCEL İ GÖRÜNÜZ YAPAR
(pl:cell-color "B1:B1" 3)
(pl:cell-value 2 "B" "HUCREYE YAZ")
(pl:cell-value 3 "B" "BİRLEŞTİRME DENEMESİ") ; PL:CELL-MERGE İÇİNDE YAZI BOLD, İTALİK, ALTI CIZGILI FİLANDA VAR İŞİNİZE GÖRE AYIRABILIRSINIZ
(pl:cell-merge "b3:c3")
(pl:cell-border-fill "B4:B4" '(1 2 3 4) -4119 3 1)
(pl:sigdir)
(setvar "cmdecho" 1)
)
;;;;;Hücre kenarlik komut (pl:cell-border-fill cell '(3 4) -4119 3 9)
(defun pl:cell-border-fill (kenarhucre brdi ltype lweight lcolor / brds tmp)
(setq cell-kenar (vlax-variant-value ;_Range
(vlax-invoke-method
MySheet
"Evaluate"
kenarhucre
) ;_ end of vlax-invoke-method
) ;_ end of vlax-variant-value
) ;_ end of setq
(setq brds (vlax-get-property cell-kenar 'borders))
(foreach i brdi
(setq tmp (vlax-get-property brds 'Item i))
(if lweight
(vlax-put-property tmp 'Weight lweight)
)
(if ltype
(vlax-put-property tmp 'LineStyle ltype)
)
(if lcolor
(vlax-put-property tmp 'ColorIndex lcolor)
)
)
(vlax-release-object cell-kenar)
;brdi - list of the integers, border index, only next values:
;1 or 7 - left
;2 or 8 - right
;3 or 9 - top
;4 or 10 - bottom
;5 - diagonal (top-left to bottom-right)
;6 - diagonal (top-right to bottom-left)
;example: '(1 2 4)
;ltype - long (integer), line style, from 0 to 13 and -4118, -4119, -4142 and may be more, some values:
;-4142 - no line
;1 - continues
;2 dash
;3 or -4118 - dot
;4 - dashdot
;5 - dashmulti3
;10 - dashmulti2
;11 - dashmulti3
;-4119 - double
;example: 1
;lweight - long (integer), line weight, from 1 to 4 and -4138 and may be more, but i think - no, values:
;1 - hair line
;2 - thin
;3 or -4138 - bold
;4 - heavy
;example: 3
;lcolor - long (integer), color, from 0 to 56 and -4105, -4142 and may be more, some values:
;-4142 - no
;-4105 - auto
;1 - black
;2 - white
;3 - red
;4 - green
;5 - blue
;6 - yellow
;7 - magenta
;8 - cyan
;9 - murrey
;10 - deep-green
;11 - deep-blue
;12 - tawny
;13 - petunia
;14 - deep-cyan
;15 - silver
;16 - grey
;17 - light-blue
;18 - maroon
;19 - flaxen
;20 - light-cyan
;example: 3
)
;;;;;;;;;Excel Hücresine Deger Yaz komut (pl:cell-value satir sutun deger)
(defun pl:cell-value( satir sutun deger)
(vlax-put-property
(vlax-variant-value ;_Range
(vlax-invoke-method
MySheet
"Evaluate"
"A1"
) ;_ end of vlax-invoke-method
)
"Item"
satir ;satir
sutun ;Sütun
(vl-princ-to-string deger)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;Excel Hücresinin Renk degisimi (pl:cell-color renkhucre renk)
(defun pl:cell-color ( renkhucre renk)
(setq cell-renk (vlax-variant-value ;_Range
(vlax-invoke-method
MySheet
"Evaluate"
renkhucre
) ;_ end of vlax-invoke-method
) ;_ end of vlax-variant-value
) ;_ end of setq
(setq obj (vlax-get-property cell-renk 'Interior)) ;_Interior
(vlax-put-property obj 'Colorindex renk) ;_Color
(vlax-release-object cell-renk)
);
;;;;;;;;;Excel Etkinlestir komut (pl:excel-ac)
(defun pl:excel-ac ()
(setq OEX (vlax-get-or-create-object "Excel.Application")) ;_Object Excell
(setq OWRB (vlax-get-property OEX 'Workbooks)) ;_Object Workbook
(setq AWB (vlax-invoke-method OWRB 'Add)) ;_Active Workbook
(setq ASH (vlax-get-property AWB "Worksheets")) ;_Active WorkSheet
(setq MySheet (vlax-invoke-method ASH 'Add)) ;_Sheet
)
;;;;;;;;;;Excel degiskenlerini serbest birakma komut (pl:close-relase)
(defun pl:close-release ()
(vlax-release-object obj)
(vlax-release-object cell)
(vlax-release-object MySheet)
(vlax-release-object ASH)
(vlax-release-object AWB)
(vlax-release-object OWRB)
(vlax-release-object OEX)
)
;;;;;;;;;;;;;EXCEL HUCRE BİRLEŞTİR VE HUCRE YAZI FONT RENK VS ÖZELLİKLERİ DEĞİŞTİRME
(defun pl:cell-merge (mercell)
(setq xlRange (vlax-get-property mysheet "Range" mercell))
(vlax-invoke-method xlRange "Select")
(setq xlRange (vlax-get-property OEX "Selection"))
(vlax-put-property xlRange "MergeCells" :vlax-true) ; HUCRE BIRLESTIREN KOMUT
;;;;;;;;ALIGNMENT;;;;;;;
(vlax-put-property xlRange "Horizontalalignment" (vlax-make-variant -4131 3)) ; YATAY HİZALAMA
;HorizontalAlignment
;The horizontal alignment for cell content
;VBA Resource: Const xlHAlignCenter = -4108 (&HFFFFEFF4)
; Const xlHAlignCenterAcrossSelection = 7
; Const xlHAlignDistributed = -4117 (&HFFFFEFEB)
; Const xlHAlignFill = 5
; Const xlHAlignGeneral = 1
; Const xlHAlignJustify = -4130 (&HFFFFEFDE)
; Const xlHAlignLeft = -4131 (&HFFFFEFDD)
; Const xlHAlignRight = -4152 (&HFFFFEFC8)
(vlax-put-property xlRange "verticalalignment" (vlax-make-variant -4108 3)) ; DÜŞEY HİZALAMA
;VerticalAlignment
;The vertical alignment for cell content
;VBA Resource: Const xlVAlignBottom = -4107 (&HFFFFEFF5)
; Const xlVAlignCenter = -4108 (&HFFFFEFF4)
; Const xlVAlignDistributed = -4117 (&HFFFFEFEB)
; Const xlVAlignJustify = -4130 (&HFFFFEFDE)
; Const xlVAlignTop = -4160 (&HFFFFEFC0)
;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; FONT İŞLEMLERİ;;;;;;;
(setq fnt (vlax-get-property xlrange "Font"))
(vlax-put-property fnt "Bold" (vlax-make-variant 1)) ; bold yapar
(vlax-put-property fnt "Italic" (vlax-make-variant 1)) ; italic yapar
(vlax-put-property fnt "underline" (vlax-make-variant 2)) ; altı çizgili yapar değerler 0 , 1 , 2 , 3 , 4 , 5..
(vlax-put-property fnt "Size" (vlax-make-variant 10));font punto buyukluk
(vlax-put-property fnt "name" (vlax-make-variant "Times New Roman"));fontu ne olsun
;(vlax-put-property fnt "colorindex" (vlax-make-variant 5));rengi ne olsun
;;;;;;;;;;;;;;;;;;;
;(vlax-dump-object (vlax-get-property (vlax-get-property mysheet 'usedrange) 'cells) T) ; HUCRENIN HANGI OZELLIKLERI ILE OYNARIZ LISTELER
)
(defun pl:sigdir ()
(vlax-invoke-method
(vlax-get-property
(vlax-get-property (vlax-get-property mysheet 'usedrange) 'cells)
'columns)
'autofit)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;