procedure
TBasePPL
.
ToExcelExecute(Sender: TObject);
var
ws,xl:variant;
i,maxrow:
integer
;
col,fst:
integer
;
begin
fst:=
2
;
xl:=createoleobject(
'Excel.Application'
);
try
maxrow:=
0
;
xl
.
visible:=
true
;
XL
.
WorkBooks
.
Add;
ws := XL
.
ActiveWorkBook
.
ActiveSheet;
ws
.
Range[
'A1'
].NumberFormat:=
'0'
;
ws
.
Range[
'A'
+inttostr(fst)].Value :=
'№'
;
ws
.
Range[
'B'
+inttostr(fst)].Value :=
'Nombres'
;
col:=
1
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(fst)].Value :=
' '
;
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(fst)].Value :=
' '
;
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(fst)].Value :=
' '
;
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(fst)].Value :=
' '
;
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(fst)].Value :=
' '
;
end
;
for
i:=fst+
1
to
Visitas
.
Items
.
Count+fst
do
begin
col:=
1
;
ws
.
Range[
'a'
+inttostr(i)].Value := i-
2
;
ws
.
Range[
'b'
+inttostr(i)].Value := Visitas
.
Items[i-fst-
1
].Caption;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(i)].Value:=Visitas
.
Items[i-fst-
1
].SubItems[
0
];
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(i)].Value:=Visitas
.
Items[i-fst-
1
].SubItems[
1
];
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(i)].Value:=Visitas
.
Items[i-fst-
1
].SubItems[
2
];
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(i)].Value:=Visitas
.
Items[i-fst-
1
].SubItems[
3
];
end
;
begin
inc(col);
ws
.
Range[Chr(Ord(
'A'
)+col)+inttostr(i)].Value:=Visitas
.
Items[i-fst-
1
].SubItems[
4
];
end
;
maxrow:=i;
end
;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeLeft].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeLeft].Weight:=xlThin;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeLeft].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeTop].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeTop].Weight:=xlThin;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeTop].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeBottom].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeBottom].Weight:=xlThin;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeBottom].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeRight].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeRight].Weight:=xlThin;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlEdgeRight].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlInsideVertical].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlInsideVertical].Weight:=xlThin;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlInsideVertical].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlInsideHorizontal].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlInsideHorizontal].Weight:=xlThin;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(maxrow)].Borders[xlInsideHorizontal].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeLeft].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeLeft].Weight:=xlMedium;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeLeft].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeTop].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeTop].Weight:=xlMedium;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeTop].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeBottom].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeBottom].Weight:=xlMedium;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeBottom].ColorIndex:=xlAutomatic;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeRight].LineStyle:=xlContinuous;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeRight].Weight:=xlMedium;
ws
.
Range[
'A'
+inttostr(fst)+
':'
+Chr(Ord(
'A'
)+col)+inttostr(fst)].Borders[xlEdgeRight].ColorIndex:=xlAutomatic;
for
i:=ord(
'A'
)
to
ORD(
'A'
)+col
do
begin
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeLeft].LineStyle:=xlContinuous;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeLeft].Weight:=xlMedium;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeLeft].ColorIndex:=xlAutomatic;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeTop].LineStyle:=xlContinuous;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeTop].Weight:=xlMedium;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeTop].ColorIndex:=xlAutomatic;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeBottom].LineStyle:=xlContinuous;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeBottom].Weight:=xlMedium;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeBottom].ColorIndex:=xlAutomatic;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeRight].LineStyle:=xlContinuous;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeRight].Weight:=xlMedium;
ws
.
Range[Chr(i)+inttostr(fst)+
':'
+Chr(i)+inttostr(maxrow)].Borders[xlEdgeRight].ColorIndex:=xlAutomatic;
end
;
ws
.
range[
'A1:'
+chr(Ord(
'A'
)+col)+
'1'
].merge;
if
(Groups
.
ItemIndex>=
0
)
and
(Groups
.
ItemIndex<groups
.
Items
.
Count)
then
ws
.
range[
'A1:'
+chr(Ord(
'A'
)+col)+
'1'
].value:=
'Lista "'
+Groups
.
Items[Groups
.
ItemIndex].Caption+
'"'
else
ws
.
range[
'A1:'
+chr(Ord(
'A'
)+col)+
'1'
].value:=
'Lista'
;
ws
.
range[
'A1:'
+chr(Ord(
'A'
)+col)+
'1'
].font
.
Bold:=
true
;
ws
.
range[
'A'
+inttostr(fst)+
':'
+chr(Ord(
'A'
)+col)+inttostr(fst)].font
.
bold:=
true
;
ws
.
Columns[
'A:'
+chr(Ord(
'A'
)+col)].EntireColumn
.
AutoFit;
xl
.
ActiveWindow
.
SplitRow:=fst;
xl
.
ActiveWindow
.
FreezePanes:=
True
;
xl
.
ActiveSheet
.
PageSetup
.
Orientation:=xlLandscape;
xl
.
ActiveSheet
.
PageSetup
.
PrintArea:=
'$A:$G'
;
finally
end
;