参考这个://将报表第iPageNo页存为WORD文件
procedure ReportSaveToDocFile(sFileName :string; iPageNo :integer);
var Template,NewTemplate,ItemIndex:OleVariant;
E: TMetaFile;
B: TBitmap;
MyFormat : Word;
AData : THandle;
APalette : HPALETTE;
begin
try
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
try
Wordapplication.Connect;
except
MessageDlg('Word may not be installed', mtError, [mbOk], 0);
Abort;
end;
Wordapplication.Visible := True;
WordApplication.Caption := 'Delphi automation';
{Create new document}
Template := EmptyParam;
NewTemplate := False;
WordApplication.Documents.Add(Template, NewTemplate);
{Assign WordDocument component}
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
{Turn Spell checking of because it takes a long time if enabled and slows down Winword}
WordApplication.Options.CheckSpellingAsYouType := False;
WordApplication.Options.CheckGrammarAsYouType := False;
{Insert data}
B := TBitmap.Create;
E := QRPreview1.QRPrinter.GetPage(iPageNo); //想要第几页
try
with TMetafileCanvas.Create(E, 0) do
try
B.Height := E.Height;
B.Width := E.Width;
B.Canvas.Draw(0, 0, E);
finally
Free;
end;
B.SaveToClipBoardFormat(MyFormat,AData,APalette);
ClipBoard.SetAsHandle(MyFormat,AData);
finally
B.Free;
end; WordDocument.Sentences.Last.Paste;
except
on E: Exception do
begin
ShowMessage(E.Message);
WordApplication.Disconnect;
end;
end;
end;
procedure ReportSaveToDocFile(sFileName :string; iPageNo :integer);
var Template,NewTemplate,ItemIndex:OleVariant;
E: TMetaFile;
B: TBitmap;
MyFormat : Word;
AData : THandle;
APalette : HPALETTE;
begin
try
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
try
Wordapplication.Connect;
except
MessageDlg('Word may not be installed', mtError, [mbOk], 0);
Abort;
end;
Wordapplication.Visible := True;
WordApplication.Caption := 'Delphi automation';
{Create new document}
Template := EmptyParam;
NewTemplate := False;
WordApplication.Documents.Add(Template, NewTemplate);
{Assign WordDocument component}
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
{Turn Spell checking of because it takes a long time if enabled and slows down Winword}
WordApplication.Options.CheckSpellingAsYouType := False;
WordApplication.Options.CheckGrammarAsYouType := False;
{Insert data}
B := TBitmap.Create;
E := QRPreview1.QRPrinter.GetPage(iPageNo); //想要第几页
try
with TMetafileCanvas.Create(E, 0) do
try
B.Height := E.Height;
B.Width := E.Width;
B.Canvas.Draw(0, 0, E);
finally
Free;
end;
B.SaveToClipBoardFormat(MyFormat,AData,APalette);
ClipBoard.SetAsHandle(MyFormat,AData);
finally
B.Free;
end; WordDocument.Sentences.Last.Paste;
except
on E: Exception do
begin
ShowMessage(E.Message);
WordApplication.Disconnect;
end;
end;
end;
解决方案 »
- 如何使treeview控件的第2级节点全部关闭????????????
- 谢谢帮助
- 郁闷!!只想散分!!!!!!!!!!!!!!!
- 应用程序如何读取web站点中的Access数据库中的数据?并将数据下载到本地。
- 异地两台电脑通过Modem通信采取什么传输方式能够更安全些?
- 如何判断计算机的当前用户是否登陆了网域(高分请教,UP有分)
- 在DSPACK中播放的别名是怎么一回事?
- 大家不要笑,一个最最基础问题
- 模拟按下TAB键
- 帮忙~
- 我收到了visual转发Kronus(Kronus)的Requirement Spec非常感谢Visual。我还想问问,那位大虾有没有实际的需求分析书例子,能让我们学习学习。
- 如何使应用程序中的窗口改变样式,比如像‘WINXP’中的窗口,比如像‘东方音都’的窗口!!
uses Clipbrd;