[原创]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> 谢谢楼主分享! 本帖最后由 作者 于 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-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/> Dim wdApp As Word.Application<br/> Dim wdDoc As Word.Document<br/> Dim wdTable As Word.Table<br/> <br/> Dim EntObj As AcadEntity<br/> Dim AttRefObjs As Variant<br/> Dim n As Integer<br/> Dim i As Integer<br/> Dim j As Integer<br/> <br/> On Error Resume Next<br/> ' 连接Word<br/> Set wdApp = GetObject(, "Word.Application")<br/> If Err Then<br/> Err.Clear<br/> Set wdApp = CreateObject("Word.Application")<br/> If Err Then<br/> Err.Clear<br/> MsgBox "无法启动Word,请检查是否正确安装!"<br/> Exit Sub<br/> End If<br/> End If<br/> wdApp.Visible = True<br/> <br/> On Error GoTo ErrTrap<br/> ' 返回新创建的文档<br/> Set wdDoc = wdApp.Documents.Add<br/> ' 返回在段落一之后新创建的表格<br/> Set wdTable = wdDoc.Tables.Add(wdDoc.Paragraphs(1).Range, 1, LBObj.ListCount)<br/> <br/> n = 0<br/> ' 遍历选择集<br/> For Each EntObj In SSetObj<br/> ' 增加行<br/> wdTable.Rows.Add<br/> ' 返回属性数据<br/> AttRefObjs = EntObj.GetAttributes<br/> n = n + 1<br/> For i = 0 To UBound(AttRefObjs)<br/> For j = 0 To LBObj.ListCount - 1<br/> If AttRefObjs(i).TagString = LBObj.List(j) And LBObj.Selected(j) = True Then<br/> If n = 1 Then<br/> ' 首行,标签做为表格的列标题<br/> wdTable.Cell(n, j + 1).Range.Text = AttRefObjs(i).TagString<br/> wdTable.Cell(n + 1, j + 1).Range.Text = AttRefObjs(i).TextString<br/> Else<br/> wdTable.Cell(n + 1, j + 1).Range.Text = AttRefObjs(i).TextString<br/> End If<br/> End If<br/> Next<br/> Next<br/> Next<br/> <br/> ' 删除表格中的空列<br/> For i = LBObj.ListCount - 1 To 0 Step -1<br/> If wdTable.Cell(1, i + 1).Range.Text = vbCr + Chr(7) Then<br/> wdTable.Columns(i + 1).Delete<br/> End If<br/> Next<br/> <br/> ' 按序号排序<br/> wdTable.Sort True, "列 1"<br/> ' 自动调整列宽<br/> wdTable.AutoFitBehavior 1<br/> <br/> ' 释放Word对象<br/> Set wdTable = Nothing<br/> Set wdDoc = Nothing<br/> Set wdApp = Nothing<br/> Exit Sub<br/> <br/>ErrTrap:<br/> On Error GoTo 0<br/>End Sub</p><p>' 导出到Excel中<br/>Public Sub OutputToExcel(ByVal SSetObj As AcadSelectionSet, ByVal LBObj As ListBox)<br/> Dim xlApp As Excel.Application<br/> Dim xlBook As Excel.Workbook<br/> Dim xlSheet As Excel.Worksheet<br/> <br/> Dim EntObj As AcadEntity<br/> Dim AttRefObjs As Variant<br/> Dim n As Integer<br/> Dim i As Integer<br/> Dim j As Integer<br/> <br/> On Error Resume Next<br/> ' 连接Excel<br/> Set xlApp = GetObject(, "Excel.Application")<br/> If Err Then<br/> Err.Clear<br/> Set xlApp = CreateObject("Excel.Application")<br/> If Err Then<br/> Err.Clear<br/> MsgBox "无法启动Word,请检查是否正确安装!"<br/> Exit Sub<br/> End If<br/> End If<br/> xlApp.Visible = True<br/> <br/> On Error GoTo ErrTrap<br/> ' 返回新创建的工作簿<br/> Set xlBook = xlApp.Workbooks.Add<br/> ' 返回新增加的工作表,并移动到最后一个<br/> Set xlSheet = xlBook.Worksheets.Add<br/> xlSheet.Move , xlBook.Worksheets(xlBook.Worksheets.Count)<br/> <br/> n = 0<br/> ' 遍历选择集<br/> For Each EntObj In SSetObj<br/> ' 返回属性数据<br/> AttRefObjs = EntObj.GetAttributes<br/> n = n + 1<br/> For i = 0 To UBound(AttRefObjs)<br/> For j = 0 To LBObj.ListCount - 1<br/> If AttRefObjs(i).TagString = LBObj.List(j) And LBObj.Selected(j) = True Then<br/> If n = 1 Then<br/> ' 首行,标签做为表格的列标题<br/> xlSheet.Cells(n, j + 1).Value = AttRefObjs(i).TagString<br/> xlSheet.Cells(n + 1, j + 1).Value = AttRefObjs(i).TextString<br/> Else<br/> xlSheet.Cells(n + 1, j + 1).Value = AttRefObjs(i).TextString<br/> End If<br/> End If<br/> Next<br/> Next<br/> Next<br/> <br/> ' 删除表格中的空列<br/> For i = LBObj.ListCount - 1 To 0 Step -1<br/> If xlSheet.Cells(1, i + 1).Value = "" Then<br/> xlSheet.Columns(i + 1).Delete<br/> End If<br/> Next<br/> <br/> ' 按序号排序<br/> xlSheet.UsedRange.Sort Key1:=Range("A2"), Header:=xlYes<br/> ' 自动调整列宽<br/> xlSheet.Columns.AutoFit</p><p> ' 释放Exccel对象<br/> Set xlSheet = Nothing<br/> Set xlBook = Nothing<br/> Set xlApp = Nothing<br/> Exit Sub<br/> <br/>ErrTrap:<br/> On Error GoTo 0<br/>End Sub</p><p>Excel VBA 范例文件代码</p> 本帖最后由 作者 于 2007-12-9 21:37:01 编辑 <br /><br /> <p>select选择集+图层Layer</p><p>Sub ls()<br/> Dim ss1 As AcadSelectionSet<br/> Dim layername As String<br/> Dim AcadEnt As AcadEntity<br/> 'Dim pp1 As AcadPoint, pp2 As AcadPoint<br/> '指定图层名称<br/> 'Set pp1 = ThisDrawing.Utility.GetPoint<br/> 'Set pp2 = ThisDrawing.Utility.GetPoint<br/> layername = "件号"<br/> Dim tt As AcadText, MTt As AcadMText<br/> '得到选择集</p><p> Dim gpCode(0) As Integer<br/> Dim dataValue(0) As Variant<br/> gpCode(0) = 8<br/> dataValue(0) = layername</p><p> Set ss1 = ThisDrawing.SelectionSets.Add("ss3")<br/> ss1.Select acSelectionSetAll, , , gpCode, dataValue<br/> 'ss1.Select acSelectionSetCrossing, pp1, pp2, , dataValue<br/>For Each AcadEnt In ss1<br/> 'Debug.Print AcadEnt.ObjectName<br/> Select Case AcadEnt.ObjectName<br/> Case "AcDbText"<br/> Set tt = AcadEnt<br/> Debug.Print tt.TextString<br/> Case "AcDbMText"<br/> Set MTt = AcadEnt<br/> Debug.Print "MText---", MTt.TextString<br/> End Select<br/>Next<br/> ss1.Delete<br/> 'ss1.Clear<br/>End Sub<br/></p><p></p> <p>支持兰州人!</p> <p>好资料</p> <p>高人阿!谢谢</p> <p>收获了很多资料 </p> 本人前不久也刚刚编写了一个cad表格自动输出到EXCEL的vba代码,基本思路就是把选择到的所有文字实体先按y坐标排序,由此可以把这些字分成若干行,每行再按纵坐标排序,确定先后顺序,缺点就是无法判断空的单元格,会导致后面的单元格内容串列. <p>很好的资料,学习,收藏</p>