[求助] 用DAO连接EXCEL为什么经常丢数据(附图)?
程序代码及跟踪结果:<IMG src="http://www.5ivb.net/club/UploadFile/2004414163637byUID3191.jpg">
EXCEL表实际内容:
<IMG src="http://www.5ivb.net/club/UploadFile/2004414163647byUID3191.jpg">
问题:表中第二行(即数据库中的MOVEFIRST)有好几个数字没有被读出,另外501的第四列550*300没有被出,512的第10列的“3”没有被读出,等等,请问各位高手是为什么,程序代码在上图中。<BR> 我连怎么样连接EXCEL都不会,请楼主先教教我基本的东西 另外501的第四列550*300没有被出
可能因为那个"*" gamelemon发表于2004-8-23 15:07:00static/image/common/back.gif我连怎么样连接EXCEL都不会,请楼主先教教我基本的东西
<p><font color="#ff0033" size="4">请问怎么连接Excel,怎么将属性块中的属性写入Excel</font></p> <p><font color="#0000ff">Sub</font> Example_IntersectWith<font color="#ff0000">(</font><font color="#ff0000">)</font><br/><br/> <font color="#0000ff">Dim</font> xlApp <font color="#0000ff">As</font> Object <font color="#008000">' This Line ,Not <font color="#0000ff">set</font> Excel , run Excel</font><br/> <font color="#008000">'Dim xlsheet <font color="#0000ff">As</font> Object</font><br/> <br/> <font color="#008000">' 发生错误时跳到下一个语句继续执行</font><br/> <font color="#0000ff">On</font>
<font color="#0000ff">Error</font>
<font color="#0000ff">Resume</font>
<font color="#0000ff">Next</font><br/> <font color="#008000">' 连接Excel应用程序</font><br/> <font color="#0000ff">Set</font> xlApp <font color="#0000ff">=</font>
<font color="#0000ff">GetObject</font><font color="#ff0000">(</font>, <font color="#880000">"Excel.<font color="#0000ff">Application</font>"</font><font color="#ff0000">)</font><br/> <br/> <font color="#0000ff">If</font> Err.Number <> 0 <font color="#0000ff">Then</font><br/> <font color="#0000ff">Set</font> xlApp <font color="#0000ff">=</font> CreateObject<font color="#ff0000">(</font><font color="#880000">"Excel.<font color="#0000ff">Application</font>"</font><font color="#ff0000">)</font><br/> xlApp.<font color="#0000ff">Visible</font>
<font color="#0000ff">=</font> True<br/> xlApp.Workbooks.<font color="#0000ff">Add</font><br/> <font color="#0000ff">End If</font><br/> <font color="#008000">' 返回当前活动的工作表</font><br/> <font color="#008000">'Set xlsheet <font color="#0000ff">=</font> xlApp.ActiveSheet</font><br/> <font color="#0000ff">Set</font> xlSheet <font color="#0000ff">=</font> xlApp.sheets<font color="#ff0000">(</font>1<font color="#ff0000">)</font><br/><br/> <font color="#008000">' This example creates a line <font color="#0000ff">and</font> circle <font color="#0000ff">and</font> finds the points at</font><br/> <font color="#008000">' which they intersect.</font><br/> <font color="#0000ff">Dim</font> oBject <font color="#0000ff">As</font>
<font color="#0000ff">AcadEntity</font>, oBject1 <font color="#0000ff">As</font>
<font color="#0000ff">AcadEntity</font><br/> <font color="#0000ff">Dim</font> ii <font color="#0000ff">As</font> Integer, jj <font color="#0000ff">As</font> Integer<br/> <font color="#0000ff">Dim</font> Ppt <font color="#0000ff">As</font> Variant<br/> nn <font color="#0000ff">=</font> 1<br/> <font color="#0000ff">For</font> ii <font color="#0000ff">=</font> 0 To <font color="#0000ff">ThisDrawing</font>.<font color="#0000ff">ModelSpace</font>.Count <font color="#0000ff">-</font> 1 <br/> <font color="#0000ff">Set</font> oBject <font color="#0000ff">=</font>
<font color="#0000ff">ThisDrawing</font>.<font color="#0000ff">ModelSpace</font>.<font color="#0000ff">Item</font><font color="#ff0000">(</font>ii<font color="#ff0000">)</font> <br/> <font color="#0000ff">For</font> jj <font color="#0000ff">=</font> 0 To <font color="#0000ff">ThisDrawing</font>.<font color="#0000ff">ModelSpace</font>.Count <font color="#0000ff">-</font> 1<br/> <font color="#0000ff">Set</font> oBject1 <font color="#0000ff">=</font>
<font color="#0000ff">ThisDrawing</font>.<font color="#0000ff">ModelSpace</font>.<font color="#0000ff">Item</font><font color="#ff0000">(</font>jj<font color="#ff0000">)</font> <br/> Ppt <font color="#0000ff">=</font> oBject1.<font color="#0000ff">IntersectWith</font><font color="#ff0000">(</font>oBject, acExtendOtherEntity<font color="#ff0000">)</font><br/> xlSheet.Cells<font color="#ff0000">(</font>nn, 1<font color="#ff0000">)</font>.<font color="#0000ff">Value</font>
<font color="#0000ff">=</font> Format<font color="#ff0000">(</font>Ppt<font color="#ff0000">(</font>0<font color="#ff0000">)</font>, <font color="#880000">"0.0"</font><font color="#ff0000">)</font><br/> xlSheet.Cells<font color="#ff0000">(</font>nn, 2<font color="#ff0000">)</font>.<font color="#0000ff">Value</font>
<font color="#0000ff">=</font> Format<font color="#ff0000">(</font>Ppt<font color="#ff0000">(</font>1<font color="#ff0000">)</font>, <font color="#880000">"0.0"</font><font color="#ff0000">)</font><br/> xlSheet.Cells<font color="#ff0000">(</font>nn, 3<font color="#ff0000">)</font>.<font color="#0000ff">Value</font>
<font color="#0000ff">=</font> Ppt<font color="#ff0000">(</font>2<font color="#ff0000">)</font><br/> Debug.Print Ppt<font color="#ff0000">(</font>0<font color="#ff0000">)</font>, Ppt<font color="#ff0000">(</font>1<font color="#ff0000">)</font>, Ppt<font color="#ff0000">(</font>2<font color="#ff0000">)</font><br/> Debug.Print nn, oBject.<font color="#0000ff">Handle</font>, oBject1.<font color="#0000ff">Handle</font><br/> xlSheet.Cells<font color="#ff0000">(</font>nn, 4<font color="#ff0000">)</font>.<font color="#0000ff">Value</font>
<font color="#0000ff">=</font> nn<br/> nn <font color="#0000ff">=</font> nn <font color="#0000ff">+</font> 1<br/> <font color="#0000ff">Next</font> jj<br/> <font color="#0000ff">Next</font> ii <br/><font color="#0000ff">End Sub</font></p><p><font color="#0000ff"></font></p><p><font color="#0000ff">直接用调用Excel</font></p><p><br/></p>
页:
[1]