CADsite

  • wo 21 08 2019, 14:58:09
  • Welkom, gast
Log in of registreer jezelf.

Login met gebruikersnaam, wachtwoord en sessielengte
Geavanceerd zoeken  

Nieuws:

Pagina's: 1 [2]   Omlaag

Auteur Topic: Excel manipulatie vanuit autocad  (gelezen 10798 keer)

WebRacer

  • vaste forumklant
  • *****
  • Offline Offline
  • Berichten: 440
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #15 Gepost op: vr 30 09 2005, 16:12:13 »

Mss eens eenvoudig beginnen HofCAD,

ik wil de lijst:  (setq Y_list '("125465.235" "456987.852" "954256.357"))
vanuit autocad in een excel blad plaatsen met als naam : Y_list.xls

en in dat blad komt in vak A1-> eerste element uit lijst, A2 tweede element, enz...

met behulp van de excel-manipulatie dsx-routines..
hoe doe je dat in godsnaam...

vandaar kunnen we dan vertrekken om verder te bouwen, want
uw routine is al redelijk ingewikkeld...
bv:
rang1 (vlax-get-property xlapp "Range" span)
rang1s (vlax-invoke-method rang1 "Select")
rang1x (vlax-get-property xlapp "Selection")
rang1f (vlax-get-property rang1x "Font")
rang1i (vlax-get-property rang1x "Interior")
rang1a (vlax-get-property rang1x "areas")


heb ik dat hiervoor nodig?

btw, uw exceltest... loopt bij mij niet... (ter info -> acad 2006)
Gelogd
?

HofCAD

  • forumverslaafde
  • ******
  • Offline Offline
  • Berichten: 1525
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #16 Gepost op: vr 30 09 2005, 16:16:10 »

Beste WebRacer,

Hier snap ik geen biet van, want bij mij loopt mijn programma goed.
Ik ben er zelfs ervoor helemaal uit AutoCAD gegaan, om het te testen.

Groetjes HofCAD CSI

(vl-load-com)

;;;*************************************************************************
;;; MODULE: DSX-TypeLib-Excel
;;; DESCRIPTION: Returns typelib (olb) file for either Excel 97, 2000, or XP
;;; ARGS: none
;;; EXAMPLE: (DSX-TypeLib-Excel)
;;;*************************************************************************

(defun DSX-TypeLib-Excel ( / sysdrv tlb)
(setq sysdrv (getenv "systemdrive"))
(cond
( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel8.olb")))
tlb
)
( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel9.olb")))
tlb
)
( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel10.olb")))
tlb
)
( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel.exe")))
tlb
)
( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office10\\Excel.exe")))
tlb
)
)
)

;;;*************************************************************************
;;; MODULE: DSX-Load-TypeLib-Excel
;;; DESCRIPTION: Loads typelib for Excel 97, 2000 or XP (whichever is found)
;;; ARGS: none
;;; EXAMPLE: (DSX-Load-TypeLib-Excel)
;;;*************************************************************************

(defun DSX-Load-TypeLib-Excel ( / tlbfile tlbver out)
(dsx-princ "\n(DSX-Load-TypeLib-Excel)")
(cond
( (null msxl-xl24HourClock)
(if (setq tlbfile (DSX-TypeLib-Excel))
(progn
(setq tlbver (substr (vl-filename-base tlbfile) 6))
(cond
( (= tlbver "9") (princ "\nInitializing Microsoft Excel 2000...") )
( (= tlbver "8") (princ "\nInitializing Microsoft Excel 97...") )
( (= (vl-filename-base tlbfile) "Excel.exe")
(princ "\nInitializing Microsoft Excel XP...")
)
)
(vlax-import-type-library
:tlb-filename tlbfile
:methods-prefix "msxl-"
:properties-prefix "msxl-"
:constants-prefix "msxl-"
)
(if msxl-xl24HourClock (setq out T))
)
)
)
( T (setq out T) )
)
out
)

;;;*************************************************************************
;;; MODULE: DSX-Open-Excel-New
;;; DESCRIPTION: Opens a new session of Excel 97, 2000 or XP
;;; ARGS: display-mode ("SHOW" or "HIDE")
;;; EXAMPLE: (setq xlapp (DSX-Open-Excel-New "SHOW"))
;;;*************************************************************************

(defun DSX-Open-Excel-New (dmode / appsession)
(dsx-princ "\n(DSX-Open-Excel-New)")
(princ "\nCreating new Excel Spreadsheet file...")
(cond
( (setq appsession (vlax-create-object "Excel.Application"))

(vlax-invoke-method
(vlax-get-property appsession 'WorkBooks)
'Add
)
(if (= (strcase dmode) "SHOW")
(vla-put-visible appsession 1)
(vla-put-visible appsession 0)
)
)
)
appsession
)

;;;*************************************************************************
;;; MODULE: DSX-Open-Excel-Exist
;;; DESCRIPTION: Gets handle to existing (running) session of Excel 97, 2000, XP
;;; ARGS: xls-filename, display-mode ("SHOW" or "HIDE")
;;; EXAMPLE: (setq xlapp (DSX-Open-Excel-Exist "myfile.xls" "SHOW"))
;;;*************************************************************************

(defun DSX-Open-Excel-Exist (xfile dmode / appsession)
(dsx-princ "\n(DSX-Open-Excel-Exist)")
(princ "\nOpening Excel Spreadsheet file...")
(cond
((setq fn (findfile xfile))
(cond
((setq appsession (vlax-get-or-create-object "Excel.Application"))
(vlax-invoke-method
(vlax-get-property appsession 'WorkBooks)
'Open
fn
)
(if (= (strcase dmode) "SHOW")
(vla-put-visible appsession 1)
(vla-put-visible appsession 0)
)
)
)
)
(T (alert (strcat "\nCannot locate source file: " xfile)))
)
appsession
)


;;;*************************************************************************
;;; MODULE: DSX-Excel-Put-ColumnList
;;; DESCRIPTION: Write each list member to a column (startcol) starting at row (startrow)
;;; ARGS: list, startrow, startcol
;;; EXAMPLE: (DSX-Excel-Put-ColumnList '("A" "B" "C") 1 2) puts members into cells (1,B) (2,B) (3,B) respectively
;;;*************************************************************************

(defun DSX-Excel-Put-ColumnList (lst startrow startcol)
(dsx-princ "\n(DSX-Excel-Put-ColumnList)")
(foreach itm lst
(msxl-put-value
(DSX-Excel-Get-Cell range startrow startcol)
itm
)
(setq startrow (1+ startrow))
); repeat
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Put-RowList
;;; DESCRIPTION: Write each list member to row (startrow) starting at column (startcol)
;;; ARGS: list, startrow, startcol
;;; EXAMPLE: (DSX-Excel-Put-RowList '("A" "B" "C") 2 1) puts members into cells (1,B) (1,C) (1,D) respectively
;;;*************************************************************************

(defun DSX-Excel-Put-RowList (lst startrow startcol)
(dsx-princ "\n(DSX-Excel-Put-RowList)")
(foreach itm lst
(msxl-put-value
(DSX-Excel-Get-Cell range startrow startcol)
itm
)
(setq startcol (1+ startcol))
); repeat
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Put-CellColor
;;; DESCRIPTION: Applies fill-color to specified cell
;;; ARGS: row, column, color (integer)
;;; EXAMPLE: (DSX-Excel-Put-CellColor 1 1 14) apply color #14 to cell (1,A)
;;;*************************************************************************

(defun DSX-Excel-Put-CellColor (row col intcol / rng)
(setq rng (DSX-Excel-Get-Cell (msxl-get-ActiveSheet xlapp) row col))
(msxl-put-colorindex (msxl-get-interior rng) intcol)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Put-RowCellsColor
;;; DESCRIPTION: Applies fill-color to a row of cells
;;; ARGS: startrow, startcol, num-cols, color (integer)
;;; EXAMPLE: (DSX-Excel-Put-RowCellsColor 1 1 5 14) Start at row=1 col=1 repeat for 5 columns using color #14
;;;*************************************************************************

(defun DSX-Excel-Put-RowCellsColor
(startrow startcol cols intcol / next)
(dsx-princ "\n(DSX-Excel-Put-RowCellsColor)")

(setq next startcol)
(repeat cols
(DSX-Excel-Put-CellColor startrow next intcol)
(setq next (1+ next))
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Put-ColumnCellsColor
;;; DESCRIPTION: Change fill color in a column of cells
;;; ARGS: startrow, startcol, num-rows, color (integer)
;;; EXAMPLE: (DSX-Excel-Put-ColumnCellsColor 1 1 5 14) Start at row=1 col=1 repeat for 5 rows using color #14
;;;*************************************************************************

(defun DSX-Excel-Put-ColumnCellsColor
(startrow startcol rows intcol / next)
(dsx-princ "\n(DSX-Excel-Put-ColumnCellsColor)")

(setq next startrow)
(repeat rows
(DSX-Excel-Put-CellColor next startcol intcol)
(setq next (1+ next))
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Get-Cell
;;; DESCRIPTION: Get cell object relative to range using (relrow) and (relcol) offsets
;;; ARGS: range-object, relative-row, relative-col
;;; EXAMPLE: (DSX-Excel-Get-Cell rng1 2 2)
;;;*************************************************************************

(defun DSX-Excel-Get-Cell (rng relrow relcol)
(dsx-princ "\n(DSX-Excel-Get-Cell)")
(vlax-variant-value
(msxl-get-item (msxl-get-cells rng)
(vlax-make-variant relrow)
(vlax-make-variant relcol)
)
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Get-CellValue
;;; DESCRIPTION: Return value in given cell (row, column) of active session object (xlapp)
;;; ARGS: row(int), column(int)
;;; EXAMPLE: (DSX-Excel-Get-CellValue 1 2)
;;;*************************************************************************

(defun DSX-Excel-Get-CellValue (row col)
(dsx-princ "\n(DSX-Excel-Get-CellValue)")

(vlax-variant-value
(msxl-get-value
(DSX-Excel-Get-Cell
(msxl-get-ActiveSheet xlapp)
row col
)
)
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Get-RowValues
;;; DESCRIPTION: Returns a list of cell values within a given row
;;; ARGS: row-number(int), startcol, num-cells
;;; EXAMPLE: (DSX-Excel-Get-RowValues 3 1 20) get first 20 values in row 3
;;;*************************************************************************

(defun DSX-Excel-Get-RowValues
(row startcol numcells / next out)
(dsx-princ "\n(DSX-Excel-Get-RowValues)")

(setq next startcol)
(repeat numcells
(setq out (if out
(append out (list (DSX-Excel-Get-CellValue row next))); row x col
(list (DSX-Excel-Get-CellValue row next)); row x col
)
next (1+ next)
)
); repeat
out
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Get-ColumnValues
;;; DESCRIPTION: Returns a list of cell values within a given column
;;; ARGS: column-number(int), startrow, num-cells
;;; EXAMPLE: (DSX-Excel-Get-ColumnValues 2 1 20) get top-20 entries in column 2 ("B")
;;;*************************************************************************

(defun DSX-Excel-Get-ColumnValues
(col startrow numcells / next out)
(dsx-princ "\n(DSX-Excel-Get-ColumnValues)")

(setq next startrow)
(repeat numcells
(setq out
(if out
(append out (list (DSX-Excel-Get-CellValue next col)))
(list (DSX-Excel-Get-CellValue next col))
)
next (1+ next)
)
); repeat
out
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-GetRangeValues-ByRows
;;; DESCRIPTION: Get range values in row order and return as nested lists
;;; ARGS: startrow, startcol, num-rows, num-cols
;;; EXAMPLE: (DSX-Excel-GetRangeValues-ByRows 1 1 3 3) get range values from 1A to 5J where each sublist is one row
;;;*************************************************************************

(defun DSX-Excel-GetRangeValues-ByRows
(startrow startcol numrows numcols / nextrow rowlst outlst)
(dsx-princ "\n(DSX-Excel-GetRangeValues-ByRows)")
(setq nextrow startrow)
(repeat numrows
(setq rowlst (DSX-Excel-Get-RowValues nextrow startcol numcols)
outlst (if outlst (append outlst (list rowlst)) (list rowlst))
nextrow (1+ nextrow)
)
)
outlst
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-GetRangeValues-ByCols
;;; DESCRIPTION: Get range values in column order and return as nested lists
;;; ARGS: startrow, startcol, num-rows, num-cols
;;; EXAMPLE: (DSX-Excel-GetRangeValues-ByCols 1 1 3 3) get range values from 1A to 5J where each sublist is one column
;;;*************************************************************************

(defun DSX-Excel-GetRangeValues-ByCols
(startrow startcol numrows numcols / nextrow nextcol collst outlst)
(dsx-princ "\n(DSX-Excel-GetRangeValues-ByCols)")
(setq nextcol startcol)
(repeat numcols
(setq collst (DSX-Excel-Get-ColumnValues nextcol startrow numrows)
outlst (if outlst (append outlst (list collst)) (list collst))
nextcol (1+ nextcol)
)
)
outlst
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Get-ActiveWorkSheet
;;; DESCRIPTION: Returns object of active worksheet in active Excel session
;;; ARGS: app (session object)
;;; EXAMPLE: (DSX-Excel-Get-ActiveWorkSheet xlapp)
;;;*************************************************************************

(defun DSX-Excel-Get-ActiveWorkSheet (xlapp)
(dsx-princ "\n(DSX-Excel-Get-ActiveWorkSheet)")
(msxl-get-ActiveSheet xlapp)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-RangeAutoFit
;;; DESCRIPTION: Applies Auto-Fit to columns within active range
;;; ARGS: active-sheet (object)
;;; EXAMPLE: (DSX-Excel-RangeAutoFit myxlws)
;;;*************************************************************************

(defun DSX-Excel-RangeAutoFit (active-sheet)
(dsx-princ "\n(DSX-Excel-RangeAutoFit)")
(vlax-invoke-method
(vlax-get-property
(vlax-get-property
(vlax-get-property active-sheet 'UsedRange)
'Cells
)
'Columns
)
'AutoFit
)
)

(defun DSX-Excel-RangeDataFormat (active-sheet)
(dsx-princ "\n(DSX-Excel-RangeDataFormat)")
(vlax-put-property
(vlax-get-property active-sheet "Cells")
'NumberFormat "@"
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Quit
;;; DESCRIPTION: Quit and close Excel session (app)
;;; ARGS: app (session object)
;;; EXAMPLE: (DSX-Excel-Quit xlapp)
;;;*************************************************************************

(defun DSX-Excel-Quit (appsession)
(dsx-princ "\n(DSX-Excel-Quit)")
(cond
( (not (vlax-object-released-p appsession))
(vlax-invoke-method appsession 'QUIT)
(vlax-release-object appsession)
)
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Kill
;;; DESCRIPTION: Forces any open Excel sessions to be closed
;;; ARGS: none
;;; EXAMPLE: (DSX-Excel-Kill)
;;;*************************************************************************

(defun DSX-Excel-Kill ( / eo)
(while (setq eo (vlax-get-object "Excel.Application"))
(DSX-Excel-Quit eo)
(vlax-release-object eo)
(setq eo nil)
(gc)(gc);; even this doesn't always kill the damn thing!
)
)

;;;*************************************************************************
;;; MODULE:
;;; DESCRIPTION:
;;; ARGS:
;;; EXAMPLE:
;;;*************************************************************************
;;; Remove trailing 'nil' members from a given list

(defun DSX-TrimList (lst)
(cond
( (/= nil (last lst)) lst)
( T
(DSX-TrimList (reverse (cdr (reverse lst))))
)
)
)

;;;*************************************************************************
;;; MODULE:
;;; DESCRIPTION:
;;; ARGS:
;;; EXAMPLE:
;;;*************************************************************************
;;; Convert a list of values into a list of string equivalents

(defun DSX-ListStr (lst / mbr out)
(setq out '())
(foreach mbr lst
(cond
( (= mbr nil) (setq out (cons "" out)) )
( (= (type mbr) 'STR)
(if (member mbr '(" " " " " "))
(setq out (cons "" out))
(setq out (cons mbr out))
)
)
( (= (type mbr) 'INT) (setq out (cons (itoa mbr) out)) )
( (= (type mbr) 'REAL)(setq out (cons (rtos mbr 2 6) out)))
)
)
(reverse out)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-Sheets
;;; DESCRIPTION: Returns SHEETS collection from active workbook
;;; ARGS: Excel-application
;;; EXAMPLE: (setq sheets (DSX-Excel-Sheets xlApp))
;;;*************************************************************************

(defun DSX-Excel-Sheets (xlapp)
(setq xlsheets (vlax-get-property xlapp "sheets"))
)

;;;*************************************************************************
;;; MODULE:DSX-Excel-SheetDelete
;;; DESCRIPTION: Delete sheet (tab) from active workbook sheets collection
;;; ARG: sheet-name, sheets-collection
;;; EXAMPLE: (DSX-Excel-SheetDelete "Sheet3" xlSheets)
;;;*************************************************************************

(defun DSX-Excel-SheetDelete (name xlsheets)
(vlax-for sh xlsheets
(if (= (vlax-get-property sh "Name") name)
(vlax-invoke-method sh "Delete")
)
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-SheetAdd
;;; DESCRIPTION: Add new sheet (tab) to sheets collection in workbook, returns sheet object
;;; ARG: sheet-name, sheets-collection
;;; EXAMPLE: (setq newsheet (DSX-Excel-SheetAdd "SheetX" xlSheets))
;;;*************************************************************************

(defun DSX-Excel-SheetAdd (name xlsheets)
(setq newsheet (vlax-invoke-method xlsheets "Add"))
(vlax-put-property newsheet "Name" name)
newsheet
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-WorkbookSave
;;; DESCRIPTION: Saves active workbook to specified filename, if file exists, it is overwritten if user accepts prompt
;;; ARG: workbook-object, filename
;;; EXAMPLE: (DSX-Excel-WorkbookSave objWB "myfile.xls")
;;;*************************************************************************

(defun DSX-Excel-WorkbookSave (workbook filename)
(if (findfile filename)
(vlax-invoke-method awb "Save")
(vlax-invoke-method awb "SaveAs"
filename msxl-xlNormal "" ""
:vlax-False :vlax-False nil
)
)
)

;;;*************************************************************************
;;; MODULE: DSX-Excel-ActiveWorkbook
;;; DESCRIPTION: Returns active workbook object from given Excel application session
;;; ARG: Excel-application
;;; EXAMPLE: (setq objWB (DSX-Excel-ActiveWorkbook xlApp))
;;;*************************************************************************

(defun DSX-Excel-ActiveWorkbook (xlapp)
(vlax-get-property xlapp "ActiveWorkbook")
)

(defun c:TestExcel2000()
(setvar "CMDECHO" 0)
(defun dsx-princ(s)
(if (/= DEBUG nil)
(princ s))
)
(DSX-TypeLib-Excel)
(DSX-Load-TypeLib-Excel)
(setq xlapp (DSX-Open-Excel-New "SHOW"))
(setq span (strcat "E1:" (chr (+ 64 (length '("A" "B" "C" "D" "E")))) "4")
range (vlax-get-property xlapp "Range" span)
)
(DSX-Excel-Put-RowList '("E1" "F1" "G1") 1 1)
(DSX-Excel-Put-RowList '("E2" "F2" "G2") 2 1)
(DSX-Excel-Put-RowList '("H3" "I3" "J3") 3 4)
(setq span (strcat "A1:" (chr (+ 64 (length '("A")))) "1")
range (vlax-get-property xlapp "Range" span)
)
(setq X_lst '(("1" "2" "3")("4" "5" "6")("7" "8" "9")))
(setq i 0)
(repeat 3
(DSX-Excel-Put-RowList (nth i x_lst) (+ i 1) 1)
(setq i(1+ i))
)
(princ "\n In Excel gelezen:\n")
(princ (DSX-Excel-GetRangeValues-ByRows 1 1 3 3))
(setq span (strcat "B5:"
(chr (+ 64 (length '("A" "B" "C"))))"20" )
rang1 (vlax-get-property xlapp "Range" span)
rang1s (vlax-invoke-method rang1 "Select")
rang1x (vlax-get-property xlapp "Selection")
rang1f (vlax-get-property rang1x "Font")
rang1i (vlax-get-property rang1x "Interior")
rang1a (vlax-get-property rang1x "areas")
range rang1
)
(foreach prop
(list
(list "ColorIndex" 35)
(list "pattern" 18 )
(list "PatternColor" 255)
(list "PatternColorIndex" 3)
)
(vlax-put-property rang1i (car prop) (cadr prop))
) ; foreach
(setq i 1)
(repeat 16
(DSX-Excel-Put-CellColor (+ 4 i) 5 i)
(setq i (1+ i))
)
(setq span (strcat "A23:" (chr (+ 64 (length '("A")))) "23")
range (vlax-get-property xlapp "Range" span)
)
(textscr)
(DSX-Excel-Put-RowCellsColor 23 1 3 3)
(DSX-Excel-Put-RowList '("HofCAD" "CSI" "Tilburg") 1 1)
(setvar "CMDECHO" 1)
(princ "\n Bovenstaand is in Excel gelezen:\n")
(princ)
)

PS Om een of andere domme reden moet je bij Excel 2007
msxl-put-value vervangen door msxl-put-value2.
« Laatst bewerkt op: di 07 02 2012, 11:09:54 door HofCAD »
Gelogd
ACADcadabra

WebRacer

  • vaste forumklant
  • *****
  • Offline Offline
  • Berichten: 440
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #17 Gepost op: vr 30 09 2005, 16:22:28 »

open excel, maar plaatst niets in het blad!!!
volledig autocad herstart en uw voorgaande data gebruikt...
Gelogd
?

WebRacer

  • vaste forumklant
  • *****
  • Offline Offline
  • Berichten: 440
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #18 Gepost op: vr 30 09 2005, 16:26:07 »

(msxl-put-value
    (DSX-Excel-Get-Cell range startrow startcol)
    itm
      )


hier spot ie ->> (DSX-Excel-Get-Cell range startrow startcol)
Gelogd
?

HofCAD

  • forumverslaafde
  • ******
  • Offline Offline
  • Berichten: 1525
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #19 Gepost op: vr 30 09 2005, 16:29:19 »

Citaat van: WebRacer

btw, uw exceltest... loopt bij mij niet... (ter info -> acad 2006)


----------- ~\\|//~ ------------
------------
  • -
  • -------------

-------ooO---(_)---Ooo--------

Beste WebRacer,

Als de bibloitheek geladen is, en er een koppeling is.
Dan gaat dit bij mij als volgt om de lijst
(setq X_lst '(("1" "2" "3")("4" "5" "6")("7" "8" "9")))
in A1>C1, A2>C2 en A3>C3 te krijgen en later te lezen.


(vl-load-com)
(defun dsx-princ(s)
(if (/= DEBUG nil)
(princ s))
)
(DSX-TypeLib-Excel)
(DSX-Load-TypeLib-Excel)
(setq xlapp (DSX-Open-Excel-New "SHOW"))
(setq span (strcat "A1:" (chr (+ 64 (length '("A")))) "1")
range (vlax-get-property xlapp "Range" span)
)
(setq X_lst '(("1" "2" "3")("4" "5" "6")("7" "8" "9")))
(setq i 0)
(repeat 3
(DSX-Excel-Put-RowList (nth i x_lst) (+ i 1) 1)
(setq i(1+ i))
)
(princ "\n In Excel gelezen:\n")
(princ (DSX-Excel-GetRangeValues-ByRows 1 1 3 3))


Dit
rang1s (vlax-invoke-method rang1 "Select")
rang1x (vlax-get-property xlapp "Selection")
rang1f (vlax-get-property rang1x "Font")
rang1i (vlax-get-property rang1x "Interior")
rang1a (vlax-get-property rang1x "areas")

heb je inderdaad niet nodig, als je niets aan het uiterlijk wilt veranderen.
 
Ik ga vanavond thuis Execeltest eens uittesten, want hier op het werk
doet het programma het goed.

Groetjes HofCAD CSI

PS Krijg je wel bij:
(setq xlapp (DSX-Open-Excel-New "SHOW"))
Excel te zien.
Gelogd
ACADcadabra

WebRacer

  • vaste forumklant
  • *****
  • Offline Offline
  • Berichten: 440
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #20 Gepost op: vr 30 09 2005, 16:45:04 »

ik krijg excel te zien, alles is geladen, het plaatst enkel de lijst NIET in excel..., waarom, het mag mij een worst wezen? mss omdat excel het niet wil? ik moest wel deze toevoegen aan (DSX-TypeLib-Excel):

((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft office\\Office11\\Excel.exe"))) tlb)
Gelogd
?

HofCAD

  • forumverslaafde
  • ******
  • Offline Offline
  • Berichten: 1525
    • Bekijk profiel
Excel manipulatie vanuit autocad
« Reactie #21 Gepost op: vr 30 09 2005, 16:53:37 »

Citaat van: WebRacer
ik krijg excel te zien, alles is geladen, het plaatst enkel de lijst NIET in excel..., waarom, het mag mij een worst wezen? mss omdat excel het niet wil? ik moest wel deze toevoegen aan (DSX-TypeLib-Excel):

((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft office\\Office11\\Excel.exe"))) tlb)


Best WebRacer,

Daar ligt het volgens mij aan.

Groetjes HofCAD CSI

PS Ik ga van het weekend genieten.
Gelogd
ACADcadabra

derockere

  • ervaren poster
  • ****
  • Offline Offline
  • Berichten: 52
    • Bekijk profiel
Re: Excel manipulatie vanuit autocad
« Reactie #22 Gepost op: di 27 03 2018, 13:04:01 »

Hoi,

Hebben jullie http://www.cadsite.be/forum/viewtopic.php?t=194 al eens geprobeerd?
Voor de rest is jullie discussie wel interessant hoor!
Groetjes
Gelogd
Pagina's: 1 [2]   Omhoog