procedure
CreateFileExcel(kolFiles:
integer
);
var
stolb :
byte
;
x, y, i:
integer
;
XL: Variant;
f:TextFile;
begin
XL := CreateOleObject(
'Excel.Application'
);
XL
.
DisplayAlerts :=
False
;
XL
.
WindowState := -
4137
;
if
not
(FileExists(stDir+
'\RPO_'
+copy(DateToStr(date),
4
,
7
)+
'.xls'
))
then
begin
XL
.
WorkBooks
.
add;
XL
.
WorkBooks[
1
].WorkSheets[
1
].Cells[
1
,
2
].Value:=
'OPS'
;
XL
.
Range[
'A1:AG'
+IntToStr(StrToInt(baza[
0
,
0
])+
1
)].Select;
XL
.
Selection
.
Borders
.
LineStyle:=
1
;
XL
.
Selection
.
VerticalAlignment:=
3
;
XL
.
Selection
.
HorizontalAlignment:=
3
;
XL
.
Selection
.
ColumnWidth:=
12
;
XL
.
Range[
'C2:AG'
+IntToStr(StrToInt(baza[
0
,
0
])+
1
)].Select;
XL
.
Selection
.
Borders
.
LineStyle:=
2
;
XL
.
Range[
'A1:A1'
].Select;
for
i:=
1
to
StrToInt(baza[
0
,
0
])
do
begin
XL
.
WorkBooks[
1
].WorkSheets[
1
].Cells[i+
1
,
1
].Value:=IntToStr(i);
XL
.
WorkBooks[
1
].WorkSheets[
1
].Cells[i+
1
,
2
].Value:=baza[i,
0
];
end
;
for
i:=
1
to
31
do
XL
.
WorkBooks[
1
].WorkSheets[
1
].Cells[
1
,i+
2
].Value:=IntToStr(i)+copy(DateToStr(date),
3
,
8
);
end
else
begin
if
FileExists(stDir+
'\RPO_'
+copy(DateToStr(date),
4
,
7
)+
'.xls'
)
then
begin
XL
.
ActiveWorkbook
.
Close;
XL
.
Application
.
Quit;
end
;
XL
.
WorkBooks
.
Open(stDir+
'\RPO_'
+copy(DateToStr(date),
4
,
7
)+
'.xls'
);
XL
.
WorkSheets[
1
].Activate;
end
;
frmMain
.
Pg
.
Position:=
0
;
frmMain
.
Pg
.
Max:=kolFiles;
for
x:=
1
to
kolFiles
do
begin
frmMain
.
PRG
.
Caption:=Files[x].Index;
for
y:=
1
to
StrToInt(baza[
0
,
0
])
do
if
Files[x].Index=baza[y,
0
]
then
begin
XL
.
WorkBooks[
1
].WorkSheets[
1
].Cells[y+
1
,StrToInt(copy(Files[x].Date,
3
,
2
))+
2
].Value:=Files[x].Name;
end
;
FileCopy(stDir+
'\UnZip\'+Files[x].Name,stDir+'
\
'+DateToStr(Date)+'
\'+Files[x].Name);
DeleteFile(stDir+'\UnZip\'+Files[x].Name);
frmMain
.
PG
.
Position:=frmMain
.
PG
.
Position+
1
;
end
;
frmMain
.
PG
.
Position:=
0
;
frmMain
.
PRG
.
Caption:=
'Creating Excel Reports Complite!!!'
;
XL
.
WorkBooks[
1
].WorkSheets[
1
].Cells[
1
,
1
].Value:=TimeToStr(Time);
XL
.
ActiveWorkbook
.
SaveAs(stDir+
'\RPO_'
+copy(DateToStr(date),
4
,
7
)+
'.xls'
);
XL
.
ActiveWorkbook
.
Close;
XL
.
Application
.
Quit;
end
;