maxI:=
13
;
for
i :=
1
to
maxI
do
begin
if
i =
1
then
dm
.
zapros
.
SQL
.
Text :=
'запрос1'
else
if
if
i =
2
then
dm
.
zapros
.
SQL
.
Text :=
'запрос2'
else
if
if
i =
3
then
dm
.
zapros
.
SQL
.
Text :=
'запрос3'
;
dm
.
zapros
.
Open;
if
not
dm
.
zapros
.
IsEmpty
then
begin
try
Exsel := CreateOleObject(
'Excel.Application'
);
Exsel
.
DisplayAlerts :=
false
;
WorkBook := Exsel
.
Workbooks
.
Add;
Sheet := WorkBook
.
WorkSheets[
1
];
r:=
1
;
while
not
dm
.
zapros
.
Eof
do
begin
if
(i
in
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
]
then
begin
Sheet
.
Cells[r,
1
].Value := dm
.
zapros
.
FieldByName(
'path'
).AsString;
Sheet
.
Cells[r,
2
].Value := dm
.
zapros
.
FieldByName(
'kol'
).AsInteger;
end
;
if
(i
in
[
1
,
2
,
8
,
11
,
12
,
13
])
then
begin
Sheet
.
Cells[r,
5
].Value := dm
.
zapros
.
FieldByName(
'E'
).AsInteger;
end
;
if
(i
in
[
3
,
4
,
7
,
9
,
10
])
then
begin
Sheet
.
Cells[r,
4
].Value:=dm
.
zapros
.
FieldByName(
'E'
).AsInteger;
end
;
if
(i
in
[
9
,
10
])
then
begin
Sheet
.
Cells[r,
7
].Value := dm
.
zapros
.
FieldByName(
'F'
).AsString;
end
;
if
(i
in
[
1
,
10
,
12
,
13
])
then
begin
Sheet
.
Cells[r,
6
].Value := dm
.
zapros
.
FieldByName(
'F'
).AsString;
end
;
if
(i
in
[
5
,
6
])
then
begin
Sheet
.
Cells[r,
6
].Value := dm
.
zapros
.
FieldByName(
'G'
).AsString;
end
;
if
(i
in
[
1
,
2
,
4
,
13
])
then
begin
Sheet
.
Cells[r,
7
].Value := dm
.
zapros
.
FieldByName(
'G'
).AsString;
end
;
if
(i
in
[
9
,
10
,])
then
begin
Sheet
.
Cells[r,
8
].Value := dm
.
zapros
.
FieldByName(
'G'
).AsString;
end
;
inc(r);
dm
.
aqLoc
.
Next;
end
;
finally
case
i
of
1
: WorkBook
.
SaveAs(Tempkp+
'\файл1 от '
+dt+
'.csv'
,
6
);
2
: WorkBook
.
SaveAs(Tempkp+
'\файл2 от '
+dt+
'.csv'
,
6
);
3
: WorkBook
.
SaveAs(Tempkp+
'\файл3 от '
+dt+
'.csv'
,
6
);
end
;
WorkBook
.
Close;
Exsel
.
Application
.
Quit;
Exsel := Unassigned;
end
;
end
;
end
;