Unit1.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:3k
源码类别:

Email服务器

开发平台:

Delphi

  1. unit Unit1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, OleCtrls, OALib_TLB;
  6. type
  7.   TForm1 = class(TForm)
  8.     Office1: TOffice;
  9.     btnCreateWord: TButton;
  10.     btnCreateExcel: TButton;
  11.     btnCreatePPT: TButton;
  12.     btnOpenOffice: TButton;
  13.     btnShowToolbars: TButton;
  14.     btnPrint: TButton;
  15.     btnOpenServer: TButton;
  16.     btnSaveServer: TButton;
  17.     btnClose: TButton;
  18.     btnExit: TButton;
  19.     procedure btnCreateWordClick(Sender: TObject);
  20.     procedure btnCreateExcelClick(Sender: TObject);
  21.     procedure btnCreatePPTClick(Sender: TObject);
  22.     procedure btnOpenOfficeClick(Sender: TObject);
  23.     procedure btnShowToolbarsClick(Sender: TObject);
  24.     procedure btnPrintClick(Sender: TObject);
  25.     procedure btnOpenServerClick(Sender: TObject);
  26.     procedure btnSaveServerClick(Sender: TObject);
  27.     procedure btnCloseClick(Sender: TObject);
  28.     procedure btnExitClick(Sender: TObject);
  29.   private
  30.     { Private declarations }
  31.   public
  32.     { Public declarations }
  33.   end;
  34. var
  35.   Form1: TForm1;
  36. implementation
  37. {$R *.dfm}
  38. procedure TForm1.btnCreateWordClick(Sender: TObject);
  39. begin
  40.   Office1.CreateNew('Word.Document')
  41. end;
  42. procedure TForm1.btnCreateExcelClick(Sender: TObject);
  43. begin
  44.   Office1.CreateNew('Excel.Sheet')
  45. end;
  46. procedure TForm1.btnCreatePPTClick(Sender: TObject);
  47. begin
  48.   Office1.CreateNew('PowerPoint.Slide')
  49. end;
  50. procedure TForm1.btnOpenOfficeClick(Sender: TObject);
  51. begin
  52.   Office1.OpenLocalDialog()
  53. end;
  54. procedure TForm1.btnShowToolbarsClick(Sender: TObject);
  55. begin
  56.   if(Office1.GetToolbarsIsShow) then
  57.     Office1.ShowToolbars(false)
  58.   else
  59.     Office1.ShowToolbars(true);
  60. end;
  61. procedure TForm1.btnPrintClick(Sender: TObject);
  62. begin
  63.   Office1.Print();
  64. end;
  65. procedure TForm1.btnOpenServerClick(Sender: TObject);
  66. begin
  67.   Office1.OpenWebFile('http://www.officeocx.com/demo/Sample.doc')
  68. end;
  69. procedure TForm1.btnSaveServerClick(Sender: TObject);
  70. begin
  71.   if(Office1.IsOpen()) then
  72.     Office1.SaveWebFile('http://www.officeocx.com/demo/SaveFile.php');
  73. //You can find your save file in http://www.officeocx.com/demo/temp.doc.
  74. //The SaveFile.php get the post request and save it to temp.doc.
  75. //Or you can call OA1.SaveWebFile('http://localhost/demo/UploadAction.aspx?FileName=temp.doc');
  76. //Or you can write a receipt method to get the Http stream.
  77. end;
  78. procedure TForm1.btnCloseClick(Sender: TObject);
  79. begin
  80.   Office1.Close();
  81. end;
  82. procedure TForm1.btnExitClick(Sender: TObject);
  83. begin
  84.   Application.Terminate;
  85. end;
  86. end.