兰州人 发表于 2007-11-27 16:28:00

[原创]Auto CAD材料一览表数据到Excel

<p></p><p>图示材料一览表是AutoCad绘制施工图最常见表现形式。有人用属性块的方法处理方法见AutoCAD vba 二次开发教程第317页。</p><p>但在实际操作过程中,材料表的数据是任意方法写的,如</p><p><table cellspacing="0" cellpadding="0" width="536" border="0" style="WIDTH: 403pt; BORDER-COLLAPSE: collapse;"><colgroup><col width="93" style="WIDTH: 70pt; mso-width-source: userset; mso-width-alt: 2976;"></col><col width="191" style="WIDTH: 143pt; mso-width-source: userset; mso-width-alt: 6112;"></col><col span="2" width="126" style="WIDTH: 95pt; mso-width-source: userset; mso-width-alt: 4032;"></col></colgroup><tbody><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl22" width="93" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 70pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><strong><font face="宋体">id</font></strong></td><td class="xl22" width="191" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 143pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><strong><font face="宋体">InsertText</font></strong></td><td class="xl22" width="126" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 95pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><strong><font face="宋体">InsertPointX</font></strong></td><td class="xl22" width="126" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 95pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><strong><font face="宋体">InsertPointY</font></strong></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357224</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">5-32</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">2.418415478</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">249.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357240</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">1.2</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">138.8666674</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">217.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357248</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">0.037</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">127.4444451</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">217.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357256</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">8</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">111.8622229</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">217.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357264</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">36</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">95.00888957</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">217.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357272</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">螺母M16</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">43.50000068</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">217.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357280</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">GB6170-86</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">17.04704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">217.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357288</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-04</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">15.76704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">161.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357296</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-06</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">15.76704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">153.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357304</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-06</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">15.76704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">129.4999997</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357376</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-04</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">15.76704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">57.49999969</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357384</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-05</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">15.76704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">49.49999969</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357392</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-05</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">15.76704513</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">41.49999969</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl23" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">2128357400</font></td><td class="xl23" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">5-30</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">2.418415478</font></td><td class="xl23" align="right" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">233.4999997</font></td></tr></tbody></table></p><p></p><p>hadle,x,y数据是无序排序。</p><p>要实现以下目标,需要进行SQL+数组排序处理。</p><p><table cellspacing="0" cellpadding="0" width="696" border="0" style="WIDTH: 522pt; BORDER-COLLAPSE: collapse;"><colgroup><col width="36" style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1152;"></col><col width="120" style="WIDTH: 90pt; mso-width-source: userset; mso-width-alt: 3840;"></col><col width="138" style="WIDTH: 104pt; mso-width-source: userset; mso-width-alt: 4416;"></col><col width="20" style="WIDTH: 15pt; mso-width-source: userset; mso-width-alt: 640;"></col><col width="147" style="WIDTH: 110pt; mso-width-source: userset; mso-width-alt: 4704;"></col><col width="36" style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1152;"></col><col width="52" style="WIDTH: 39pt; mso-width-source: userset; mso-width-alt: 1664;"></col><col width="147" style="WIDTH: 110pt; mso-width-source: userset; mso-width-alt: 4704;"></col></colgroup><tbody><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl24" width="36" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 27pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">5-1</font></td><td class="xl24" width="120" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 90pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">07RH09-03</font></td><td class="xl24" width="138" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 104pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">固定管板I</font></td><td class="xl24" width="20" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 15pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">1</font></td><td class="xl24" width="147" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 110pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">16Mn/0Cr18Ni10Ti</font></td><td class="xl24" width="36" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 27pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体"> </font></td><td class="xl24" width="52" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 39pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">914.5</font></td><td class="xl24" width="147" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 110pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">其中不锈钢66.5kg</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td class="xl24" height="19" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">5-3</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">GB9948.SHJ405</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">接管 DN20 Sch80</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">2</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">20</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">0.2</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">0.4</font></td><td class="xl24" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><font face="宋体">L=108</font></td></tr></tbody></table></p>

zhouzhiy 发表于 2017-11-8 18:02:23

谢谢楼主分享!

兰州人 发表于 2007-11-27 16:35:00

本帖最后由 作者 于 2008-7-23 14:48:48 编辑

SQL+mdb处理方法
' 从数据库中读取数据
Sub ReadFromMdbFile()
    ' 创建数据库连接
    Dim YCount, nn As Integer
    Dim XDistinct, YDistinct
    Call CreateConnection
    Dim rst As ADODB.Recordset, ii As Integer
    ' 在line表中查询所有的记录
    Set rst = New ADODB.Recordset
    rst.CursorLocation = adUseClient
'Distinct Y 统计Y坐标的不重复数量
    rst.Open "SELECT val(format(InsertPointY,'0.00')) FROM EntityText" & _
         " Group By val(Format(InsertPointY,'0.00'))" & _
         " Order By val(Format(InsertPointY,'0.00'))" & _
         "", cn, adOpenForwardOnly, _
            adLockBatchOptimistic, adCmdText
    rst.MoveFirst
    ReDim YDistinct(rst.RecordCount - 1)
    For ii = 0 To rst.RecordCount - 1
      YDistinct(ii) = rst.Fields(0).Value
      Debug.Print YDistinct(ii)
      rst.MoveNext
    Next ii
    rst.Close
1.5
9.5
17.5
25.5
33.5
41.5
49.5
57.5
65.5
73.5
81.5
89.5
97.5

'Distinct X 统计X坐标的不重复数据的数量
    rst.Open "SELECT val(format(InsertPointX,'0')) FROM EntityText" & _
         " WhereFormat(InsertPointY,'0.00') = " & YDistinct(0) & _
         "", cn, adOpenForwardOnly, _
            adLockBatchOptimistic, adCmdText
    rst.MoveFirst
    ReDim XDistinct(rst.RecordCount - 1)
    For ii = 0 To rst.RecordCount - 1
      XDistinct(ii) = rst.Fields(0).Value
      Debug.Print XDistinct(ii)
      rst.MoveNext
    Next ii
    rst.Close
运行结果8列数的X坐标范围。
3
16
44
96
102
137
148

End Sub
相关的ADO帮助文件.


2008-7-23Sub ExcelToCadTable()
ThisDrawing.ActiveTextStyle.fontFile = "c:\windows\fonts\SIMHEI.ttf"
Dim colArray, rowBaseData
colArray = Array(404.55, 424, 455.11, 499, 510.11, 540.11, 550.69, 561.64)
rowBaseData = 84.71 - 6 - 8
Dim objText As AcadText
Dim xlSheet1
Dim pp(0 To 2) As Double, ppp(0 To 2) As Double, alignmentPoint(0 To 2) As Double
Set xlSheet1 = ConnectExcel("Sheet1")
For ii = 40 To 1 Step -1
    For jj = 0 To UBound(colArray) - 1
      pp(0) = colArray(jj) + 2
      pp(1) = rowBaseData + 8
      tt = xlSheet1.Cells(ii, jj + 1)
      Select Case jj
      Case 5, 6
          If Val(tt) < 1 And Val(tt) > 0 Then
            tt = "0" & tt
          End If
      End Select
      Set objText = ThisDrawing.ModelSpace.AddText(tt, pp, 4)
      alignmentPoint(1) = pp(1)
      Select Case jj
      Case 2, 7
          alignmentPoint(0) = colArray(jj) + 2
          objText.Alignment = acAlignmentLeft
          'objText.TextAlignmentPoint = alignmentPoint
      Case Else
          alignmentPoint(0) = colArray(jj) + (colArray(jj + 1) - colArray(jj)) / 2
          objText.Alignment = acAlignmentCenter
          objText.TextAlignmentPoint = alignmentPoint
      End Select
      '
    Next jj
    rowBaseData = rowBaseData + 8
Next ii
End Sub

兰州人 发表于 2007-11-28 08:44:00

本帖最后由 作者 于 2007-12-9 21:32:46 编辑 <br /><br /> <p>AutoCAD2006以上版本使用属性块的方法如下</p><p>' 导出到Word中<br/>Public Sub OutputToWord(ByVal SSetObj As AcadSelectionSet, ByVal LBObj As ListBox)<br/>&nbsp;&nbsp;&nbsp; Dim wdApp As Word.Application<br/>&nbsp;&nbsp;&nbsp; Dim wdDoc As Word.Document<br/>&nbsp;&nbsp;&nbsp; Dim wdTable As Word.Table<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim EntObj As AcadEntity<br/>&nbsp;&nbsp;&nbsp; Dim AttRefObjs As Variant<br/>&nbsp;&nbsp;&nbsp; Dim n As Integer<br/>&nbsp;&nbsp;&nbsp; Dim i As Integer<br/>&nbsp;&nbsp;&nbsp; Dim j As Integer<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; ' 连接Word<br/>&nbsp;&nbsp;&nbsp; Set wdApp = GetObject(, "Word.Application")<br/>&nbsp;&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set wdApp = CreateObject("Word.Application")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "无法启动Word,请检查是否正确安装!"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; wdApp.Visible = True<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error GoTo ErrTrap<br/>&nbsp;&nbsp;&nbsp; ' 返回新创建的文档<br/>&nbsp;&nbsp;&nbsp; Set wdDoc = wdApp.Documents.Add<br/>&nbsp;&nbsp;&nbsp; ' 返回在段落一之后新创建的表格<br/>&nbsp;&nbsp;&nbsp; Set wdTable = wdDoc.Tables.Add(wdDoc.Paragraphs(1).Range, 1, LBObj.ListCount)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; n = 0<br/>&nbsp;&nbsp;&nbsp; ' 遍历选择集<br/>&nbsp;&nbsp;&nbsp; For Each EntObj In SSetObj<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 增加行<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdTable.Rows.Add<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 返回属性数据<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AttRefObjs = EntObj.GetAttributes<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n = n + 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To UBound(AttRefObjs)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For j = 0 To LBObj.ListCount - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If AttRefObjs(i).TagString = LBObj.List(j) And LBObj.Selected(j) = True Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If n = 1 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 首行,标签做为表格的列标题<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdTable.Cell(n, j + 1).Range.Text = AttRefObjs(i).TagString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdTable.Cell(n + 1, j + 1).Range.Text = AttRefObjs(i).TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdTable.Cell(n + 1, j + 1).Range.Text = AttRefObjs(i).TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 删除表格中的空列<br/>&nbsp;&nbsp;&nbsp; For i = LBObj.ListCount - 1 To 0 Step -1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If wdTable.Cell(1, i + 1).Range.Text = vbCr + Chr(7) Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdTable.Columns(i + 1).Delete<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 按序号排序<br/>&nbsp;&nbsp;&nbsp; wdTable.Sort True, "列 1"<br/>&nbsp;&nbsp;&nbsp; ' 自动调整列宽<br/>&nbsp;&nbsp;&nbsp; wdTable.AutoFitBehavior 1<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 释放Word对象<br/>&nbsp;&nbsp;&nbsp; Set wdTable = Nothing<br/>&nbsp;&nbsp;&nbsp; Set wdDoc = Nothing<br/>&nbsp;&nbsp;&nbsp; Set wdApp = Nothing<br/>&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp; <br/>ErrTrap:<br/>&nbsp;&nbsp;&nbsp; On Error GoTo 0<br/>End Sub</p><p>' 导出到Excel中<br/>Public Sub OutputToExcel(ByVal SSetObj As AcadSelectionSet, ByVal LBObj As ListBox)<br/>&nbsp;&nbsp;&nbsp; Dim xlApp As Excel.Application<br/>&nbsp;&nbsp;&nbsp; Dim xlBook As Excel.Workbook<br/>&nbsp;&nbsp;&nbsp; Dim xlSheet As Excel.Worksheet<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim EntObj As AcadEntity<br/>&nbsp;&nbsp;&nbsp; Dim AttRefObjs As Variant<br/>&nbsp;&nbsp;&nbsp; Dim n As Integer<br/>&nbsp;&nbsp;&nbsp; Dim i As Integer<br/>&nbsp;&nbsp;&nbsp; Dim j As Integer<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; ' 连接Excel<br/>&nbsp;&nbsp;&nbsp; Set xlApp = GetObject(, "Excel.Application")<br/>&nbsp;&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set xlApp = CreateObject("Excel.Application")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "无法启动Word,请检查是否正确安装!"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; xlApp.Visible = True<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error GoTo ErrTrap<br/>&nbsp;&nbsp;&nbsp; ' 返回新创建的工作簿<br/>&nbsp;&nbsp;&nbsp; Set xlBook = xlApp.Workbooks.Add<br/>&nbsp;&nbsp;&nbsp; ' 返回新增加的工作表,并移动到最后一个<br/>&nbsp;&nbsp;&nbsp; Set xlSheet = xlBook.Worksheets.Add<br/>&nbsp;&nbsp;&nbsp; xlSheet.Move , xlBook.Worksheets(xlBook.Worksheets.Count)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; n = 0<br/>&nbsp;&nbsp;&nbsp; ' 遍历选择集<br/>&nbsp;&nbsp;&nbsp; For Each EntObj In SSetObj<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 返回属性数据<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AttRefObjs = EntObj.GetAttributes<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n = n + 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To UBound(AttRefObjs)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For j = 0 To LBObj.ListCount - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If AttRefObjs(i).TagString = LBObj.List(j) And LBObj.Selected(j) = True Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If n = 1 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 首行,标签做为表格的列标题<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.Cells(n, j + 1).Value = AttRefObjs(i).TagString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.Cells(n + 1, j + 1).Value = AttRefObjs(i).TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.Cells(n + 1, j + 1).Value = AttRefObjs(i).TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 删除表格中的空列<br/>&nbsp;&nbsp;&nbsp; For i = LBObj.ListCount - 1 To 0 Step -1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If xlSheet.Cells(1, i + 1).Value = "" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.Columns(i + 1).Delete<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 按序号排序<br/>&nbsp;&nbsp;&nbsp; xlSheet.UsedRange.Sort Key1:=Range("A2"), Header:=xlYes<br/>&nbsp;&nbsp;&nbsp; ' 自动调整列宽<br/>&nbsp;&nbsp;&nbsp; xlSheet.Columns.AutoFit</p><p>&nbsp;&nbsp;&nbsp; ' 释放Exccel对象<br/>&nbsp;&nbsp;&nbsp; Set xlSheet = Nothing<br/>&nbsp;&nbsp;&nbsp; Set xlBook = Nothing<br/>&nbsp;&nbsp;&nbsp; Set xlApp = Nothing<br/>&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp; <br/>ErrTrap:<br/>&nbsp;&nbsp;&nbsp; On Error GoTo 0<br/>End Sub</p><p>Excel VBA 范例文件代码</p>

兰州人 发表于 2007-12-5 15:43:00

本帖最后由 作者 于 2007-12-9 21:37:01 编辑 <br /><br /> <p>select选择集+图层Layer</p><p>Sub ls()<br/>&nbsp; Dim ss1 As AcadSelectionSet<br/>&nbsp; Dim layername As String<br/>&nbsp; Dim AcadEnt As AcadEntity<br/>&nbsp; 'Dim pp1 As AcadPoint, pp2 As AcadPoint<br/>&nbsp; '指定图层名称<br/>&nbsp; 'Set pp1 = ThisDrawing.Utility.GetPoint<br/>&nbsp; 'Set pp2 = ThisDrawing.Utility.GetPoint<br/>&nbsp; layername = "件号"<br/>&nbsp; Dim tt As AcadText, MTt As AcadMText<br/>&nbsp; '得到选择集</p><p>&nbsp; Dim gpCode(0) As Integer<br/>&nbsp; Dim dataValue(0) As Variant<br/>&nbsp; gpCode(0) = 8<br/>&nbsp; dataValue(0) = layername</p><p>&nbsp; Set ss1 = ThisDrawing.SelectionSets.Add("ss3")<br/>&nbsp; ss1.Select acSelectionSetAll, , , gpCode, dataValue<br/>&nbsp; 'ss1.Select acSelectionSetCrossing, pp1, pp2, , dataValue<br/>For Each AcadEnt In ss1<br/>&nbsp; 'Debug.Print AcadEnt.ObjectName<br/>&nbsp; Select Case AcadEnt.ObjectName<br/>&nbsp;&nbsp;&nbsp; Case "AcDbText"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set tt = AcadEnt<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.Print tt.TextString<br/>&nbsp;&nbsp;&nbsp; Case "AcDbMText"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set MTt = AcadEnt<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.Print "MText---", MTt.TextString<br/>&nbsp; End Select<br/>Next<br/>&nbsp; ss1.Delete<br/>&nbsp; 'ss1.Clear<br/>End Sub<br/></p><p></p>

muzi2005888 发表于 2007-12-30 16:32:00

<p>支持兰州人!</p>

zy19860604 发表于 2008-1-13 12:32:00

<p>好资料</p>

sooma 发表于 2008-1-31 22:46:00

<p>高人阿!谢谢</p>

sunny2008 发表于 2008-2-25 19:01:00

<p>收获了很多资料 </p>

ecepdiky 发表于 2008-4-2 20:36:00

本人前不久也刚刚编写了一个cad表格自动输出到EXCEL的vba代码,基本思路就是把选择到的所有文字实体先按y坐标排序,由此可以把这些字分成若干行,每行再按纵坐标排序,确定先后顺序,缺点就是无法判断空的单元格,会导致后面的单元格内容串列.

wamjsq 发表于 2009-12-12 10:39:00

<p>很好的资料,学习,收藏</p>
页: [1] 2 3 4
查看完整版本: [原创]Auto CAD材料一览表数据到Excel