procedure Trf_IncDocAAN.btnExportarClick(Sender: TObject);
var
LineNumber, LCID : Integer;
LineString : String;
begin
inherited;
if radiogroup1.ItemIndex = 0 then
begin
with SaveDialog1 do
begin
FileName := '';
Filter := 'Excel files|*.XLS;All Files|*.*';
DefaultExt := 'xls';
Title := 'Exportando a Excel';
if execute then
begin
qryIncDocmensual.Open;
LCID := GetUserDefaultLCID;
with ExcelApplication1 do
begin
connect;
try
visible[LCID] := true;
Workbooks.Add(EmptyParam,LCID);
Range['A1','T1'].Value2 := VarArrayOf(['Mes','Documento','Apellido y Nombre','Rama de Enza.','Código del cargo','Carga Horaria','Tipo De Cargo',
'Sit. de revista','Subv.','Asist.','Código Liquid./ Clave Identif.','Clave Identif.','Haberes Brutos','Haberes Líquidos','Años A.',
'Obra Soc.','Sexo','Cuil','CUE','Niveles de Enza.']);
with Range['A1','T1'] do
begin
HorizontalAlignment := xlcenter;
VerticalAlignment := xlBottom;
Wraptext := false;
orientation := 0;
ShrinkTofit := false;
MergeCells := false;
font.Bold := true;
end;
qryIncDocMensual.First;
LineNumber := 1;
while not qryIncDocMensual.Eof do
begin
if qryIncDocMensualtotalAntig.IsNull then
antiguedad := qryIncDocMensualAntig.Value
else
antiguedad := qryIncDocMensualtotalAntig.Value;
hscarga := qryIncDocMensualhoras_carga.AsInteger;
if hscarga < 10 then
hs := '''0'+inttostr(hscarga)+'00'
else
hs := inttostr(hscarga)+'00';
if qryIncDocMensualhoras_carga.AsInteger <= 0 then
hstotal:= inttostr(qryIncDocMensualcarga_c.AsInteger)
else
hstotal := hs;
if strtoint(trim(qryIncDocMensualdni.Value)) < 10000000 then
dni := qryIncDocMensualsexodni.Value
else
dni :=qryIncDocMensualdni.AsString;
if qryIncDocMensualperiodoRetro.IsNull then
periodo := qryIncDocMensualperiod.AsInteger
else
periodo := qryIncDocMensualPeriodoRetro.Value;
Inc(LineNumber);
LineString := IntToStr(LineNumber);
Range['A'+LineString,'T'+LineString].Value2:=
VarArrayOf([periodo,dni,qryIncDocMensualname_full.Value,
qryIncDocMensualrama.Value,qryIncDocMensualcod_cargo.Value,hstotal,
qryIncDocMensualPersonal.Value,qryIncDocMensualSitRev.Value,qryIncDocMensualsubv.Value,
qryIncDocMensualAsist.Value,qryIncDocMensualcodigoliquid.Value,qryIncDocMensualclave.Value,
formato(qryIncDocMensualbruto.AsFloat,6),formato(qryIncDocMensualneto.AsFloat,6),
antiguedad,qryIncDocMensualobra_social.Value,qryIncDocMensualsexo.Value,
qryIncDocMensualcuil.Value,qryIncDocMensualcode_denominational.Value,qryIncDocMensualnivel.Value]);
qryIncDocMensual.Next;
end;
Range['A1','T'+ LineString].AutoFormat(xlRangeAutoFormatList1,true,true,false,true,true,true);
Range['A1','T'+ LineString].Columns.AutoFit;
Range['A1','T'+ LineString].HorizontalAlignment := xlcenter;
ActiveWorkbook.SaveAs(filename,null,null,null,false,false,xlnochange,
xlUserResolution,false,null,null,LCID,0);
Quit;
finally
disconnect;
end;end;end;end;end;
if radiogroup2.ItemIndex = 0 then
begin
with SaveDialog1 do
begin
FileName := '';
Filter := 'Excel files|*.XLS;All Files|*.*';
DefaultExt := 'xls';
Title := 'Exportando a Excel';
if execute then
begin
qryPrimerSemestre.Open;
LCID := GetUserDefaultLCID;
with ExcelApplication1 do
begin
connect;
try
visible[LCID] := true;
Workbooks.Add(EmptyParam,LCID);
Range['A1','R1'].Value2 := VarArrayOf(['Codigo APS','Mes','Documento','Apellido y Nombre','Rama Enza.','Código del Cargo','Carga Horaria',
'Tipo de Cargo','Sit. Revista','Subvención','Asist.','Clave identif.','Años de Antiguedad','O. social',
'Sexo','Cuil','CUE','Nivel']);
with Range['A1','R1'] do
begin
HorizontalAlignment := xlcenter;
VerticalAlignment := xlBottom;
Wraptext := false;
orientation := 0;
ShrinkTofit := false;
MergeCells := false;
font.Bold := true;
end;
qryPrimerSemestre.First;
LineNumber := 1;
while not qryPrimerSemestre.Eof do
begin
if (qryPrimerSemestreCarga_horaria.IsNull) and (qryPrimerSemestreCarga_C.IsNull) then
hsTotal := 'Nulo' else
begin
if qryPrimerSemestrecarga_horaria.AsInteger <= 0 then
hstotal := qryPrimerSemestrecarga_c.AsString
else
hstotal := qryPrimerSemestrecarga_horaria.AsString;
end;
if strtoint(trim(qryPrimerSemestredni.Value)) < 10000000 then
dni := qryPrimerSemestresexodni.Value
else
dni := qryPrimerSemestredni.AsString;
if qryprimerSemestretotalantig.IsNull then
antiguedad := qryPrimerSemestreAntig.Value
else
antiguedad := qryPrimerSemestretotalAntig.Value;
if qryPrimerSemestrerama2.IsNull then
ramaEnza := qryprimerSemestrerama.Value
else
ramaEnza := qryPrimerSemestreRama2.Value;
if qryPrimerSemestreasist.IsNull then
asist := qryPrimerSemestreasist1.AsInteger
else
asist := qryPrimerSemestreasist.AsInteger;
if asist > 30 then
asist := 30;
Inc(LineNumber);
LineString := IntToStr(LineNumber);
Range['A'+LineString,'R'+LineString].Value2:=
VarArrayOf([qryPrimerSemestreenrollment_code.value,qryPrimerSemestreperiod.Value,dni,qryPrimerSemestrename_full. Value,ramaEnza,
qryPrimerSemestrecod_cargo.Value,hstotal,qryPrimerSemestrepersonal.Value,qryPrimerSemestresitRev.Val ue,
qryPrimerSemestresubv.Value,asist,qryPrimerSemestreclave.Value,antiguedad,
qryPrimerSemestreobra_social.Value,qryPrimerSemestresexo.Value,qryPrimerSemestreCuil.Value,qryPrimer Semestrecode_denominational.Value,
qryPrimerSemestrenivel.Value]);
qryPrimerSemestre.Next;
end;
Range['A1','R'+ LineString].AutoFormat(xlRangeAutoFormatList1,true,true,true,true,true,true);
Range['A1','R'+ LineString].Columns.AutoFit;
Range['A1','R'+ LineString].HorizontalAlignment := xlcenter;
ActiveWorkbook.SaveAs(FileName,null,null,null,false,false,xlnochange,
xlUserResolution,false,null,null,LCID,0);
Quit;
finally
disconnect;
end;
end;
end;
end;
end
else
begin
with SaveDialog1 do
begin
FileName := '';
Filter := 'Excel files|*.XLS;All Files|*.*';
DefaultExt := 'xls';
Title := 'Exportando a Excel';
if execute then
begin
qrySegundoSemestre.Open;
LCID := GetUserDefaultLCID;
with ExcelApplication1 do
begin
connect;
try
visible[LCID] := true;
Workbooks.Add(EmptyParam,LCID);
Range['A1','R1'].Value2 := VarArrayOf(['Codigo APS','Mes','Documento','Apellido y Nombre','Rama Enza.','Código del Cargo','Carga Horaria',
'Tipo de Cargo','Sit. Revista','Subvención','Asist.','Clave identif.','Años de Antiguedad','O. social',
'Sexo','Cuil','CUE','Nivel']);
with Range['A1','R1'] do
begin
HorizontalAlignment := xlcenter;
VerticalAlignment := xlBottom;
Wraptext := false;
orientation := 0;
ShrinkTofit := false;
MergeCells := false;
font.Bold := true;
end;
qrySegundoSemestre.First;
LineNumber := 1;
while not qrySegundoSemestre.Eof do
begin
if (qrySegundoSemestreCarga_horaria.IsNull) and (qrySegundoSemestreCarga_C.IsNull) then
hsTotal := 'Nulo' else
begin
if qrySegundoSemestrecarga_horaria.AsInteger <= 0 then
hstotal := qryPrimerSemestrecarga_c.AsString
else
hstotal := qrySegundoSemestrecarga_horaria.AsString;
end;
if strtoint(trim(qrySegundoSemestredni.Value)) < 10000000 then
dni := qrySegundoSemestresexodni.Value
else
dni := qrySegundoSemestredni.AsString;
if qryprimerSemestretotalantig.IsNull then
antiguedad := qrySegundoSemestreAntig.Value
else
antiguedad := qrySegundoSemestretotalAntig.Value;
if qrySegundoSemestrerama2.IsNull then
ramaEnza := qrySegundoSemestrerama.Value
else
ramaEnza := qrySegundoSemestreRama2.Value;
if qrySegundoSemestreasist.IsNull then
asist := qrySegundoSemestreasist1.AsInteger
else
asist := qrySegundoSemestreasist.AsInteger;
if asist > 30 then
asist := 30;
Inc(LineNumber);
LineString := IntToStr(LineNumber);
Range['A'+LineString,'R'+LineString].Value2:=
VarArrayOf([qrySegundoSemestreenrollment_code.value,qrySegundoSemestreperiod.Value,dni,qrySegundoSemestrename_fu ll.Value,ramaEnza,
qrySegundoSemestrecod_cargo.Value,hstotal,qrySegundoSemestrepersonal.Value,qrySegundoSemestresitRev. Value,
qrySegundoSemestresubv.Value,asist,qrySegundoSemestreclave.Value,antiguedad,
qrySegundoSemestreobra_social.Value,qrySegundoSemestresexo.Value,qrySegundoSemestreCuil.Value,qrySeg undoSemestrecode_denominational.Value,
qrySegundoSemestrenivel.Value]);
qrySegundoSemestre.Next;
end;
Range['A1','R'+ LineString].AutoFormat(xlRangeAutoFormatList1,true,true,true,true,true,true);
Range['A1','R'+ LineString].Columns.AutoFit;
Range['A1','R'+ LineString].HorizontalAlignment := xlcenter;
ActiveWorkbook.SaveAs(FileName,null,null,null,false,false,xlnochange,
xlUserResolution,false,null,null,LCID,0);
Quit;
finally
disconnect;
end;
end;
end;
end;
end;
qryIncDocMensual.Close;
qrySegundoSemestre.Close;
qryprimersemestre.Close;
end;