espero que ahora se vea.
gracias por tu respuesta, pero no encuentro como ligarlo a lo que estoy haciendo, como veras yo mando primero a excel y despues imprimo la hoja de excel, lo que imprimo lo saco de un query utilizo los Zeos delphi 2010 y TexcelAplication.
Código Delphi
[-]
procedure TFpuntoventa.imprime();
var
Format: OleVariant;
Hoja : _WorkSheet;
i, j : integer;
con: string;
begin
with ZQexcel do
begin
Close;
SQL.Clear;
SQL.Add('select * from tiket ');
Open;
end;
Excel.Connect;
Excel.WorkBooks.Add(NULL,0);
Hoja := Excel.Worksheets.Item[1] as _WorkSheet;
Hoja.Name := 'REPORTE';
with Hoja.range['A1','D8'] do
begin
Font.Size:=7;
Font.FontStyle := 'Bold';
HorizontalAlignment := xlCenter;
VerticalAlignment := xlCenter;
WrapText:= true;
end;
Hoja.Range['A1','D1'].MergeCells := true;
Hoja.Range['A1','D1'].Value2 := Label15.Caption;
Hoja.Range['A2','D2'].MergeCells := true;
Hoja.Range['A2','D2'].Value2 := Label13.Caption;
Hoja.Range['A3','D3'].MergeCells := true;
Hoja.Range['A3','D3'].Value2 := Label14.Caption;
Hoja.Range['A4','D4'].MergeCells := true;
Hoja.Range['A4','D4'].Value2 := Label4.Caption;
Hoja.Range['A5','D5'].MergeCells := true;
Hoja.Range['A5','D5'].Value2 := Label16.Caption+': '+Label7.Caption;
Hoja.Range['A6','D6'].MergeCells := true;
Hoja.Range['A6','D6'].Value2 := 'ticket No.'+ Label12.Caption;
Hoja.Range['A7','D7'].MergeCells := true;
Hoja.Range['A7','D7'].Value2 := IntToStr(ZQexcel.RecordCount) +' Articulos';
Hoja.Range['A8','A8'].Value2 := 'CANT';
Hoja.Range['A8','A8'].ColumnWidth := 4;
Hoja.Range['B8','B8'].Value2 := 'DESCRIPCION';
Hoja.Range['C8','C8'].Value2 := 'PRECIO';
Hoja.Range['C8','C8'].ColumnWidth := 6;
Hoja.Range['D8','D8'].Value2 := 'TOTAL';
Hoja.Range['D8','D8'].ColumnWidth := 6;
with ZQExcel do
begin
i:=9;
if not IsEmpty then
begin
while not Eof do
begin
Hoja.Range['A'+IntToStr(i),'A'+IntToStr(i)].Value2 := ZQExcel.FieldByName('cantidad').AsString;
Hoja.Range['B'+IntToStr(i),'B'+IntToStr(i)].Value2 := ZQExcel.FieldByName('descripcion').AsString;
Hoja.Range['C'+IntToStr(i),'C'+IntToStr(i)].Value2 := ZQExcel.FieldByName('precio').AsString;
Hoja.Range['D'+IntToStr(i),'D'+IntToStr(i)].Value2 := ZQExcel.FieldByName('total').AsString;
Hoja.Range['A'+inttostr(i),'D'+inttostr(i)].HorizontalAlignment := xlLeft;
Hoja.Range['A'+inttostr(i),'D'+inttostr(i)].VerticalAlignment := xlCenter;
Hoja.Range['A'+inttostr(i),'D'+inttostr(i)].Font.Size:=7;
Hoja.Range['A'+inttostr(i),'D'+inttostr(i)].WrapText:= true;
next;
i:=i+1;
end;
Format := '$#,##0.00_)';
i:=i+1;
j:=i;
Hoja.Range['B'+IntToStr(i),'B'+IntToStr(i)].Value2 := 'EFECTIVO';
Hoja.Range['D'+IntToStr(i),'D'+IntToStr(i)].Value2 := Edit3.Text;
i:=i+1;
Hoja.Range['B'+IntToStr(i),'B'+IntToStr(i)].Value2 := 'CAMBIO';
Hoja.Range['D'+IntToStr(i),'D'+IntToStr(i)].Value2 := Edit5.Text;
i:=i+1;
Hoja.Range['B'+IntToStr(i),'B'+IntToStr(i)].Value2 := 'TOTAL';
Hoja.Range['D'+IntToStr(i),'D'+IntToStr(i)].Value2 := Edit4.Text;
with Hoja.Range['B'+inttostr(j),'B'+inttostr(i)] do
begin
Font.Size:=7;
HorizontalAlignment := xlLeft;
VerticalAlignment := xlCenter;
Font.FontStyle := 'Bold';
WrapText:= true;
end;
with Hoja.Range['C'+inttostr(j),'D'+inttostr(i)] do
begin
Font.Size:=7;
HorizontalAlignment := xlLeft;
VerticalAlignment := xlCenter;
EntireColumn.NumberFormat := Format;
WrapText:= true;
end;
i:=i+2;
Hoja.Range['B'+IntToStr(i),'B'+IntToStr(i)].Value2 := 'GRACIAS POR SU PREFERENCIA';
Hoja.Range['A'+inttostr(i),'D'+inttostr(i)].MergeCells := true;
end;
end;
if not DirectoryExists('C:\SSM\Ticket\') then CreateDir('C:\SSM\Ticket\');
Excel.ActiveWorkbook.SaveAs( ExtractFilePath( 'C:\SSM\Ticket\' ) + 'ticket No.'+ Label12.Caption +'.xlsx ',EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, xlNoChange, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);
Excel.Visible[1]:=False;
Excel.Worksheets.PrintOut(null, null, 1, null, null, null, null, null, 0);
Excel.Quit;
end;