找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 642|回复: 0

[表格] (XD::Table:SetColumnWidth)设置表格的列宽

[复制链接]

已领礼包: 51个

财富等级: 招财进宝

发表于 2016-7-19 11:16:41 | 显示全部楼层 |阅读模式
函数发布
函数名称: XD::Table:SetColumnWidth
调用格式: (XD::Table:SetColumnWidth tb width col)
参数说明: tb -------------- ATable or XTable or "SHEET"
width ---------- 1、 宽度表 (0列宽度 1列宽度....)
2、 实数或整数
col -------------- 列号(WIDTH为表的时候,该参数不起作用)
返回值: T OR NIL
函数简介: 设置表格的列宽
函数来源: 原创
函数作者: Lispboy
适用版本: XDRX API 
最后更新时间: 2016-07-19
备注: width为表的时候,从列0顺序开始,有几个算几个,不一定要给全部的列
演示图片: -

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 Lispboy 于 2016-7-19 11:20 编辑

  1. (defun XD::Table:SetColumnWidth (tb width col / box box1 cols ents ents2
  2.                                     ents3 height i mat row typ v w
  3.                                 )
  4.   (setq typ (XD::Table:TYPE tb))
  5.   (cond
  6.     ((= typ "X")
  7.       (setq cols (XD::Table:numColumns tb)
  8.             rows (XD::Table:numRows tb)
  9.       )
  10.       (cond
  11.         ((= (type width) 'LIST)
  12.           (setq i 0)
  13.           (repeat (length width)
  14.             (XD::Table:setcolumnwidth tb (nth i width) i)
  15.             (setq i (1+ i))
  16.           )
  17.         )
  18.         ((or
  19.            (= (type width) 'REAL)
  20.            (= (type width) 'INT)
  21.          )
  22.           (cond
  23.             ((= (type col) 'INT)
  24.               (if (XD::Table:isValidRowColumn tb 0 col)
  25.                 (progn
  26.                   (setq w (XD::Table:ColumnWidth tb col)
  27.                         v (list (- width w) 0 0.0)
  28.                   )
  29.                   (setq ents (XD::Table:getentbyColumn tb col col)
  30.                         ents2 (cadr ents)
  31.                   )
  32.                   (if (not ents2)
  33.                     (setq ents3 (car ents))
  34.                     (setq ents3 ents2)
  35.                   )
  36.                   (setq box (xdrx_entity_box ents3
  37.                                              (XD::Table:direction tb)
  38.                             )
  39.                         box (xd::pnts:close box)
  40.                         box1 (apply
  41.                                'xdrx_points_offset
  42.                                (cons (/ w 5.0) box)
  43.                              )
  44.                         box1 (xd::pnts:close box1)
  45.                   )
  46.                   (if ents2
  47.                     (progn
  48.                       (setq ents (XD::Table:getentbyColumn tb col cols))
  49.                     )
  50.                     (progn
  51.                       (setq mat (xdrx_matrix_identity 3)
  52.                             mat (xdrx_matrix_settranslation mat
  53.                                                             (list
  54.                                                                   (/ w 2.0)
  55.                                                                   0 0.0
  56.                                                             )
  57.                                 )
  58.                             box1 (xdrx_points_transform box1 mat)
  59.                       )
  60.                     )
  61.                   )
  62.                   (xdrx_entity_stretch (append
  63.                                          (car ents)
  64.                                          (last ents)
  65.                                        ) box1 v
  66.                   )
  67.                   (xdrx_object_regen tb)
  68.                   1
  69.                 )
  70.               )
  71.             )
  72.             (t
  73.               (setq i 0)
  74.               (repeat cols
  75.                 (XD::Table:setColumnWidth tb width i)
  76.                 (setq i (1+ i))
  77.               )
  78.             )
  79.           )
  80.         )
  81.       )
  82.     )
  83.     ((= typ "A")
  84.       (cond
  85.         ((= (type width) 'LIST)
  86.           (setq i 0)
  87.           (repeat (length width)
  88.             (xdrx_table_setColumnWidth tb i (nth i width))
  89.             (setq i (1+ i))
  90.           )
  91.         )
  92.         ((or
  93.            (= (type width) 'INT)
  94.            (= (type width) 'REAL)
  95.          )
  96.           (xdrx_table_setColumnWidth tb col width)
  97.         )
  98.         (t
  99.           (xdrx_table_setColumnWidth tb width)
  100.         )
  101.       )
  102.       (xdrx_object_regen tb)
  103.     )
  104.     ((= typ "E")
  105.       ((= (type width) 'LIST) (setq i 0)
  106.        (repeat (length width)
  107.          (xdex_sheet_setColWidth i (nth i width))
  108.          (setq i (1+ i))
  109.        )
  110.       )
  111.       ((or
  112.          (= (type width) 'INT)
  113.          (= (type width) 'REAL)
  114.        )
  115.        (xdex_sheet_setColWidth col width)
  116.       )
  117.       (t
  118.         (xdex_sheet_setColWidth width)
  119.       )
  120.     )
  121.   )
  122. )


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-25 10:31 , Processed in 0.159938 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表