Ребята помогите пожалуйста экспортировать данные с DBGrid'a и с DBLookupListBox
Код:
function GetProgramPath : String;
begin
GetProgramPath:=ExtractFilePath(ParamStr(0));
end;
function GetPath:String;
begin
GetPath:=GetProgramPath+'/Data/Templates/Word/template.doc';
end;
procedure TMaterialExForm.ButtonExClick(Sender: TObject);
var
DocName, FN, gp, Psw, PswTmp, Revert, WritePsw, WritePswTmp, Fmt, Index: OleVariant;
_Prod, Prod,ConfConv,ReadOnly,AddToRecFiles,replace, FalseParam: OleVariant;
TrueParam: OleVariant;
Wrap : OleVariant;
i1 : OleVariant;
SP : OleVariant;
EP : OleVariant;
i : integer;
EmptyParam: OleVariant;
S,S1 : string;
begin
Gauge.Visible:=True;
DocName:=GetProgramPath+'/Data/Templates/Word/template.doc';
ConfConv:=true;
ReadOnly:=False;
AddToRecFiles:=False;
Psw:='';
PswTmp:='';
Revert:=False;
WritePsw:='False';
WritePswTmp:='False';
Fmt:=WdOpenFormatAuto;
FalseParam:=False;
TrueParam:=True;
Wrap:=WdFindContinue;
WordApplication.Connect;
WordApplication.Documents.OpenOld(DocName, ConfConv, ReadOnly, AddToRecFiles, Psw, PswTmp, Revert, WritePsw, WritePswTmp, Fmt);
WordDocument.ConnectTo(WordApplication.ActiveDocument);
Replace:=WdReplaceAll;
Index:=0;
for i:=1 to WordApplication.Documents.Count do
begin
i1:=i;
S:=FN;
if Pos('.',S)<>0
then S:=Copy(S,1,Pos('.',S));
S:=S+'doc';
S1:=WordApplication.Documents.Item(I1).Name;
S:=ExtractFileName(S);
S1:=ExtractFileName(S1);
if UpperCase(S1)=UpperCase(S) then
begin
WordApplication.Visible:=True;
SP:=wdPromptToSaveChanges;
EP:=wdOriginalDocumentFormat;
WordApplication.Documents.Item(i1).Close(SP,EP,EP);
end;
end;
gp:=GetProgramPath+'/Report/'+'Учет материала.doc';
WordDocument.SaveAs(gp);
//Формы вывода//
Gauge.Progress:=Gauge.Progress+9;
_Prod:='MNAIM';
Prod:=MacrosForm.MNAIM.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='COD';
Prod:=MacrosForm.COD.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='NORM';
Prod:=MacrosForm.NORM.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='CENA';
Prod:=MacrosForm.CENA.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='NAIMYA';
Prod:=MacrosForm.NAIMYA.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='POST';
Prod:=MacrosForm.POST.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='PRIHODVKOL';
Prod:=MacrosForm.PRIHODVKOL.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='PRIHODDATE';
Prod:=MacrosForm.PRIHODDATE.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='VIDANNA';
Prod:=MacrosForm.VIDANNA.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
Gauge.Progress:=Gauge.Progress+9;
_Prod:='VCEH';
Prod:=MacrosForm.VCEH.Text;
WordDocument.Range.Find.ExecuteOld(_Prod, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, Prod, replace);
WordApplication.Application.Visible:=True;
WordApplication.Disconnect;
Gauge.Progress:=0;
MaterialExForm.Close;
end;