delphi7 读取word文件 delphi 读取word - 电脑|办公 - 电脑办公-杀毒安全-网络-V3学习网
微商网
 
 
导航:首页 |电脑|办公|正文

delphi7 读取word文件 delphi 读取word

时间:2020-06-29 09:51:03
delphi7 怎样快速读取文本文件的最后一行?var strs: TStringList;line: string;parts: TStringList;strs := TStringList Cr
作者:

delphi7 读取word文件

delphi7 怎样快速读取文本文件的最后一行?

var strs: TStringList;line: string;parts: TStringList;strs := TStringList.Create;trystrs.LoadFromFile(Filename);line := strs[strs.Count - 1]; //这就是你要读取的内容//分解过程, 将分隔符替换为换行符line := StringReplace(line, "--" , sLIneBreak, [rfReplaceAll]);parts := TStringList.Create;parts.Text := line;//按下表读取parts[0], parts[1].....就可以得到分割好的每一段了parts.Free;finallystrs.free;end;

谁来帮我用Delphi 7做一个读取二进制文件的程序啊?

我将我的商用《旅行社管理系统》的 发团通知 部分奉献给您,望对您有所帮助。

procedure TFrmMain.N327Click(Sender: TObject); var FWord :Variant; FDoc :Variant; strSQL :string; begin //首先创造对象,如果出现异常就做出提示 try FWord := CreateOleObject("Word.Application"); //WOrd程序的执行是否可见,值为false时,程序在后台运行。

FWord.Visible := True; except messagebox(0,"创建word对象失败!","警告",MB_OK+MB_ICONINFORMATION); exit; end; strSQL :="select * From "B_T_Company_Infor""; with dm.ClientDataSet_Temp do begin if Active then Active:=False; CommandText:=strSQL; Open; end; //现在打开的Word中,创建一个新的页面,然后在其中键入需要的内容 try FDOC :=FWord.Documents.Add; {对于Word的新页面} FWord.Selection.Font.Name :="宋体"; FWord.Selection.Font.Size :=20; FWord.Selection.Font.Bold :=2; FWord.Selection.paragraphs.Alignment := wdAlignParagraphCenter; FWord.Selection.TypeText(dm.ClientDataSet_Temp.Fields[0].AsString); FWord.Selection.Typeparagraph;//换行 FWord.Selection.Typeparagraph; FWord.Selection.paragraphs.Alignment := wdAlignParagraphLeft; FWord.Selection.Font.Size :=12; FWord.Selection.Font.Bold :=0; FWord.Selection.TypeText(" 现将我社组团部的"); FWord.Selection.TypeText(" "); FWord.Selection.TypeText("团计划发出,各地请按下列行程做接待,并及早落实"+ "团队计划和选派优秀导游员。

各地代订住宿、火车票、机票务必安排好接待,日程"+ "如有变更,及时与下站接待社或本社联系,各地接团时请举【"+ dm.ClientDataSet_Temp.Fields[0].AsString+"】接站牌。

"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("请速回传真确认,谢谢合作!"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("人数:"); FWord.Selection.TypeText("人数:"); FWord.Selection.TypeText("国籍:"); FWord.Selection.TypeText("国籍:"); FWord.Selection.TypeText("等级:"); FWord.Selection.TypeText("等级:"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("这里是团队安排"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("TO: "); FWord.Selection.TypeText("12345678901234567890"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("TEL: "); FWord.Selection.TypeText("12345678901234567890"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("FAX: "); FWord.Selection.TypeText("12345678901234567890"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("______________________________________________"); FWord.Selection.Typeparagraph;//换行 FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("FROM: "); FWord.Selection.TypeText(dm.ClientDataSet_Temp.Fields[0].AsString); FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("TEL: "); FWord.Selection.TypeText(dm.ClientDataSet_Temp.Fields[3].AsString); FWord.Selection.Typeparagraph;//换行 FWord.Selection.TypeText("FAX: "); FWord.Selection.TypeText(dm.ClientDataSet_Temp.Fields[4].AsString); FWord.Selection.Typeparagraph;//换行 Except on e: Exception do Messagebox(0,Pchar(e.Message),"警告",MB_OK+MB_ICONINFORMATION); end; //保存文档 FWord.Caption := "组团计划保存在: "+ExtractFilePath(application.ExeName)+"Reports\GroupPlan.doc"; FDOC.SaveAS(ExtractFilePath(application.ExeName)+"Reports\GroupPlan.doc"); if messagebox(0,"组团计划已经保存成功!"+chr(13)+chr(13)+ "单击【确定】退出Word,返回到程序中!","您确信要退出Word吗?", MB_YESNO+MB_ICONINFORMATION+MB_DEFBUTTON2)=IDYES then begin FWord.Quit; FWord := Unassigned; end; end; ----------------------------- Delphi与Word之间的融合技术(1) 一、VBA代码含义 Microsoft Word是一个集成化环境,是美国微软公司的字处理系统,但是它决不仅仅是一个字处理系统,它集成了Microsoft Visual Basic,可以通过编程来实现对Word功能的扩展。

Microsoft Visual Basic在word中的代码即Word的宏,通过编写Word宏,可实现一些文档处理的自动化,如实现文档的自动备份、存盘等,可扩展Word文档的功能,因此,能够充分利用Word的特性,甚至使Word成为自己软件的一部分。

Word的宏既有有利的一部分,因为它能够帮助我们实现文档的自动化,但是Word的宏也不是纯粹的有利,有时它可能危害我们的文档、计算机系统甚 至网络,从最开始的Taiwan NO1宏病毒到现在的...

如何使用XlsReadWriteII在Delphi中读取Excel文件

procedure TForm1.Button1Click(Sender: TObject);vartmplist: tstringlist;i, j: integer;tel: string;begintel := "1300000000"; //指定电话号码 如果用edit1控件则改成 edit1.texttmplist := tstringlist.Create; //创建tmplist.LoadFromFile("文件路径"); //载入文本,路径自行确定for i:= 0 to tmplist.Count - 1 do //循环beginif pos(tel, tmplist.Strings[i]) >0 then //当查到电话号码所在行时beginj := 1;while j beginmemo1.lines.add(tmplist.Strings[i + j]); //将后10行记录写入memoinc(j); //j递增1end;break;end;end;tmplist.Free;end;//由于文本文件的内容示例没有,不知道排列,只能大致写一个,楼主可以根据文本的排列规则进行修改,不明处可以追问

大家还关注
    
阅读排行
推荐阅读