delphi 怎么把word,excel保存在数据库中 1、请问怎么把word,excel文档,还有其它图像文件保存在数据库中2、怎么把保存在数据库中的word,excel文档内容显示在memo上面3、怎么用相应的格式直接打开保存在数据库中的文档文件,例如用word打开保存在数据库中的word文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.打开word文件。 procedure TfjfsglForm.SpeedButton4Click(Sender: TObject); var MSWord: Variant; str:string; begin if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then begin str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString); MSWord:= CreateOLEObject('Word.Application');// MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);// MSWord.Visible:=1;// str:=''; MSWord.ActiveDocument.Range(0, 0);// MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title' MSWord.ActiveDocument.Range.InsertParagraphAfter; end else showmessage(''); end;(2)word文件传入和传出数据库。 uses IdGlobal; procedure TdjhyForm.SpeedButton2Click(Sender: TObject); var sfilename:string; function BlobContentTostring(const Filename:string):string; begin with Tfilestream.Create(filename,fmopenread) do try setlength(result,size); read(pointer(result)^,size); finally free; end; end; begin if opendialog1.Execute then begin sfilename:=opendialog1.FileName; DataModule1.ADOQuery14.Edit; DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename); DataModule1.ADOQuery14.Post; end; end; procedure TdjhyForm.SpeedButton1Click(Sender: TObject); var sfilename:string; bs:Tadoblobstream; begin bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread); try sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString); sfilename:=sfilename+'.'+'doc'; bs.SaveToFile(sfilename); try djhyopenform:=Tdjhyopenform.Create(self); djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false); djhyopenform.OleContainer1.Iconic:=true; djhyopenform.ShowModal; finally djhyopenform.Free; end; finally bs.free; end; end; 50分:一个存储过程的问题 怎么判断一个字符串中含有某某字符呢? 我有个过程要在窗体完全显示完的时候立即执行一次,,要写什么地方? MDI字窗中设置的快捷键不能用? delphi学习交流群,欢迎加入!群号:4118980 数据库恢复时出现的问题 外挂如何开发 在线等:如何使得TListView的列中的数据显示为右对齐? 关于快捷键,不容易,但也不难。 QuickReport控件 希望熟悉delphi调用excel的朋友解答,越多越好,分不够再加 如何把數據庫中查詢得到的表導入到excel生成報表?
procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
var
MSWord: Variant;
str:string;
begin
if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
begin
str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
MSWord:= CreateOLEObject('Word.Application');//
MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
MSWord.Visible:=1;//
str:='';
MSWord.ActiveDocument.Range(0, 0);//
MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
end
else
showmessage('');
end;
(2)word文件传入和传出数据库。
uses IdGlobal;
procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
var
sfilename:string;
function BlobContentTostring(const Filename:string):string;
begin
with Tfilestream.Create(filename,fmopenread) do
try
setlength(result,size);
read(pointer(result)^,size);
finally
free;
end;
end;
begin
if opendialog1.Execute then
begin
sfilename:=opendialog1.FileName;
DataModule1.ADOQuery14.Edit;
DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename);
DataModule1.ADOQuery14.Post;
end;
end;
procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;