国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Delphi > 正文

Delphi與Word(三)取得Word文件的數(shù)據(jù)

2019-11-18 18:35:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
,

//取得Word文件的數(shù)據(jù)
PRocedure getWordStr;
var WordApp: TWordapplication;
    WordDoc: TWordDocument;
    DocInx,oFileName,CfCversions,oReadOnly,AddToRctFiles,PswDocument,
    PswTemplate,oRevert,wpswDocument,WPswTemplate,oFormat: OleVariant;
    i,iRow,iCol:integer;
    myCell:Cell;
    myRow:Row;
begin
  memo1.Lines.Clear ;

    // ===== 創(chuàng)建對(duì)象 =====
    if not Assigned(WordApp) then                         
    begin
      WordApp:= TWordApplication.Create(nil);
      WordApp.Visible := false;
    end;
    if not Assigned(WordDoc) then
      WordDoc:= TWordDocument.Create(nil);
  try
    DocInx:=1;
    oFileName := 'd:/test.doc';
    oReadOnly:=true;
    CfCversions := EmptyParam;
    AddToRctFiles:= EmptyParam;
    PswDocument:= EmptyParam;
    PswTemplate:= EmptyParam;
    oRevert:= EmptyParam;
    WPswDocument:= EmptyParam;
    WPswTemplate:= EmptyParam;
    oFormat:= EmptyParam;    
    // ===== 打開(kāi)文件 =====                        
    WordApp.Documents.open(oFileName,CfCversions,oReadOnly,AddToRctFiles,
       PswDocument,PswTemplate,oRevert,WPswDocument,WPswTemplate,oFormat);
    // ===== 關(guān)聯(lián)文件 =====
    WordDoc.ConnectTo(WordApp.Documents.Item(DocInx));


    //方法(1): 取整個(gè)文本的字符內(nèi)容,包含表格
    s := WordDoc.Range.text; 

    //方法(2): 取 1 -- 4 位的字符 ,包含表格
    myRange:=WordDoc.Range;
    myRange.Start:=0;
    myRange.End_ :=4;

  finally
    if Assigned(WordDoc) then              // ===== 關(guān)閉文件 =====
    begin
      WordDoc.Close;
      WordDoc.Disconnect;
      WordDoc.Destroy;
      WordDoc := nil;
    end;
    if Assigned(WordApp) then              // ===== 關(guān)閉Word =====
    begin
      WordApp.Quit;
      WordApp.Disconnect;
      WordApp.Destroy;
      WordApp := nil;
    end;
  end;
end;



上一篇:delphi一句話(huà)幫助終

下一篇:Delphi與Excel

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
學(xué)習(xí)交流
熱門(mén)圖片

新聞熱點(diǎn)

疑難解答

圖片精選

網(wǎng)友關(guān)注

主站蜘蛛池模板: 蒙山县| 高碑店市| 道孚县| 囊谦县| 深州市| 商南县| 晋城| 昂仁县| 汤阴县| 舟曲县| 莱芜市| 江川县| 礼泉县| 清原| 启东市| 兰考县| 武宁县| 高青县| 汾阳市| 四平市| 疏勒县| 尼勒克县| 常州市| 芒康县| 阜宁县| 双柏县| 荆州市| 昌平区| 崇阳县| 满洲里市| 日土县| 阿坝县| 凤山市| 灵丘县| 乌拉特后旗| 介休市| 聊城市| 罗源县| 思茅市| 五台县| 伊吾县|