明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1851|回复: 9

怎么得到框选中的EXCEL中的区域的单位名字

[复制链接]
发表于 2010-7-30 10:22:00 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2010-7-30 10:47:00 | 显示全部楼层
同样想知道答案,帮你顶一个!
发表于 2010-7-30 22:57:00 | 显示全部楼层

我的这个函数稍微改一下,也许就能满足你的要求:

(defun TBxl:GetSelection (app / Col tmp range r rn c cn)
  (defun Col (x / n y z ch)
    (setq n  26
   x  (1- x)
   y  (fix (/ x n))
   z  (- x (* y n))
   ch (chr (+ 65 z))
    )
    (if (< 0 y)
      (strcat (Col y) ch)
      ch
    )
  )

  (setq range (msxl-get-selection app)
 tmp   (msxl-get-rows range)
 r     (msxl-get-row tmp)
 rn    (msxl-get-count tmp)
 tmp   (msxl-get-columns range)
 c     (msxl-get-column tmp)
 cn    (msxl-get-count tmp)
 tmp   (strcat (Col c)
        (itoa r)
        ":"
        (Col (+ c cn -1))
        (itoa (+ r rn -1))
       )
 range   (msxl-get-range app tmp)
  )
  (msxl-select range)
  (list range r c rn cn)
)

发表于 2010-8-1 11:50:00 | 显示全部楼层

好像不行,如何用啊!

发表于 2010-8-1 16:01:00 | 显示全部楼层

列首(Vlax-Get (Vlax-Get (Vlax-Get-Or-Create-Object "excel.application" ) 'Selection) 'Column )

列数(Vlax-Get (Vlax-Get (Vlax-Get (Vlax-Get-Or-Create-Object "excel.application" ) 'Selection) 'Columns) 'Count )

行首(Vlax-Get (Vlax-Get (Vlax-Get-Or-Create-Object "excel.application" ) 'Selection) 'Row )

行数(Vlax-Get (Vlax-Get (Vlax-Get (Vlax-Get-Or-Create-Object "excel.application" ) 'Selection) 'Rows) 'Count )

发表于 2010-8-1 16:27:00 | 显示全部楼层

哎,还是帮你改好吧!

(defun GetRange (range / Col tmp r rn c cn)
  (defun Col (x / n y z ch)
    (setq n  26
   x  (1- x)
   y  (fix (/ x n))
   z  (- x (* y n))
   ch (chr (+ 65 z))
    )
    (if (< 0 y)
      (strcat (Col y) ch)
      ch
    )
  )

  (setq tmp   (msxl-get-rows range)
 r     (msxl-get-row tmp)
 rn    (msxl-get-count tmp)
 tmp   (msxl-get-columns range)
 c     (msxl-get-column tmp)
 cn    (msxl-get-count tmp)
 tmp   (strcat (Col c)
        (itoa r)
        ":"
        (Col (+ c cn -1))
        (itoa (+ r rn -1))
       )
  )
  tmp
)

 

Command: (getrange (Vlax-Get (Vlax-Get-Or-Create-Object "excel.application" ) 'Selection))
返回结果:"C8:D11"

当然,在调用此函数前,要先加载EXCEL类型库。

发表于 2010-8-1 16:29:00 | 显示全部楼层
tengte发表于2010-8-1 16:27:00哎,还是帮你改好吧! (defun GetRange (range / Col tmp r rn c cn)  (defun Col (x / n y z ch)    (setq n  26   x  (1- x)   y 

发表于 2010-8-1 16:29:00 | 显示全部楼层
no function definition: MSXL-GET-ROWS
发表于 2010-8-2 12:23:00 | 显示全部楼层
我写得很清楚,要先加载EXCEL类型库。你没有写过类似的程序吧!先到网上查一查这方面的资料吧!
发表于 2010-8-2 13:06:00 | 显示全部楼层
574531868发表于2010-7-30 10:22:00比如框选中的范围是C5:H15,我想用程序知道是\"C5:H15\"这个字符串

楼主liminnet ,人家回答你要记得要感谢

又用马甲来提问。

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-2 08:35 , Processed in 0.194689 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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