2008/10/09 | VFP 读出word表格数据
类别(数据库学习笔记) | 评论(0) | 阅读(98) | 发表于 17:00

SET TALK OFF
SET SAFETY OFF
*CLEAR ALL
CLOSE ALL tables

CREATE TABLE xsinfo (xh c(20),zy c(20), lxdh c(20), kh c(20),ksh c(20), sfzh c(20))


 
 ole=createobject("Word.application")
 ole.visible=.T.
 bb=GETFILE('doc')
 aa=ole.Documents.open(bb)
*!*  input "输入表格的行数:" to iRow
*!*  input "输入表格的列数:" to icol

    dd=''
    *dd=CHR(13)+CHR(10)
    *dd=CHR(10)+CHR(13)

  
   
 FOR i=2 TO  aa.tables.item(1).Rows.count&&iRow
   
    SELECT  xsinfo
    APPEND BLANK   
    
     FOR  j=1 TO FCOUNT()
        sf=fields(j)  
        REPLACE &sf  WITH aa.tables.item(1).Cell(i,j).range.text
       
        sv=&sf
        DO while AT(dd,sv)>0
           sv=STUFF(sf,AT(dd,sv),LEN(dd),'')
        ENDDO
       
        REPLACE &sf WITH sv
       
       
     ENDFOR
    
       
    ?RECNO()
 EndFor  

 aa.close
 ole.quit

 

SET SAFETY ON
SET TALK ON

0

评论Comments