Results 1 to 2 of 2

Thread: excel with lisp command

  1. #1
    Member
    Join Date
    2014-04
    Posts
    2
    Login to Give a bone
    0

    Default excel with lisp command

    hi;
    sorry my english;
    How to change the text font in excel cell with lisp
    How to change the text height in excel cell with lisp
    How to change the text italic , bold, etc. in excel cell with lisp
    How to change the text format in excel cell with lisp ( date ,text or number and #.## or Ø#.##)

    thank you

  2. #2
    Member
    Join Date
    2014-04
    Posts
    2
    Login to Give a bone
    0

    Default Re: excel with lisp command

    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)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Last edited by Ed Jobe; 2015-03-27 at 09:46 PM. Reason: Added Code Tags

Similar Threads

  1. Excel VBA to Lisp
    By LSElite in forum AutoLISP
    Replies: 7
    Last Post: 2015-02-05, 07:31 PM
  2. Help for assign data from excel to lisp command
    By ravindra.mvk468963 in forum AutoLISP
    Replies: 2
    Last Post: 2011-09-27, 03:07 PM
  3. Replies: 3
    Last Post: 2009-10-22, 10:19 PM
  4. Visual LISP to Excel
    By avinash00002002 in forum AutoLISP
    Replies: 1
    Last Post: 2006-04-09, 03:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •