那你就在循环里面,每个单元格,用上面说的,设置具体单元格的样式就行了
 - (defun C:tt (/
- ) ;设置明细栏的宽度
- (Vl-Load-Com)
- (setq def_clms 8) ;默认总列数为8
- ;(setq def_width_list (list 7.5 7.5 33 8 36 46 16 26));A4列宽度列表
- (setq def_width_list (list 7.5 7.5 33 8 45 47 17 33))
- ;A3~A0列宽度列表
- (setq def_height_list (list 6))
- (setq def_cellheight_list (list 3.5))
- (if (setq e (ssget ":E:N" '((0 . "ACAD_TABLE"))))
- (setq tableobj (vlax-ename->vla-object (ssname e 0)))
- )
- (Vlax-Put-Property tableobj 'VertCellMargin 0) ;表格上下边距调为0
- ;设置文字样式
- ;(setq textstyle "table_sty")
- ;(command "-STYLE" textstyle "isocp.shx" def_cellheight_list 0.8 0 "N" "N" )
- (setq clms (vla-get-columns tableobj))
- (setq col 0)
- (repeat clms
- (setq width (nth col def_width_list))
- (vla-SetColumnWidth tableobj col width)
- (setq col (1+ col))
- )
- (setq rows (vla-get-rows tableobj))
- (setq row 0)
- (repeat rows
- (setq height (nth 0 def_height_list))
- (vla-SetRowHeight tableobj row height)
- (setq cellheight (nth 0 def_cellheight_list))
- (setq sub_col 0)
- ;每行时,对每列的单元格文字高度进行设置
- (repeat clms
- (vla-setcelltextheight tableobj row sub_col cellheight)
- ;设置单元格的文字高度
- (cond
- ((or (= sub_col 2) (= sub_col 7)) ;
- (vla-SetCellAlignment tableobj row sub_col acMiddleLeft) ;
- )
- ((= sub_col 2) ;
- (vla-SetCellAlignment tableobj row sub_col acMiddleRight) ;
- )
- (T ;
- (vla-SetCellAlignment tableobj row sub_col acMiddleCenter) ;
- )
- )
- (vlax-invoke
- tableobj 'setcelltextstyle row sub_col "table_sty")
- (setq sub_col (1+ sub_col))
- )
- (setq row (1+ row))
- )
- (princ)
- )
|