我把完整的导出代码给你看一下:
downName:='c:\'+ZYJ_XTCZHS.TZYJ_XTCZHS.GetDateBaseTime2('yyyy-mm-ddhh24mi')+'.xls';
case pagecontrol1.ActivePageIndex of
0 ataGrid1.SaveToXLS(downName,true);
1 ataGrid2.SaveToXLS(downName,true);
2 ataGrid3.SaveToXLS(downName,true);
end;
tempoleContainer1:=TOleContainer.Create(nil);
tempoleContainer1.Parent:=self.Panel2;
tempoleContainer1.AllowActiveDoc :=false;
tempoleContainer1.AllowInPlace :=false;
tempoleContainer1.AutoActivate :=tAutoActivate.aaManual;
tempoleContainer1.CreateObjectFromFile(downName,false);
tempoleContainer1.DoVerb (OleCtnrs.ovOpen);//打开附件
Borland.Delphi.Windows.DeleteFile(downName); //删除附件 |