Advertisement
Guest User

Untitled

a guest
Nov 29th, 2013
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. procedure TFlistadoLlamadas.Button1Click(Sender: TObject);
  2. var
  3.     workBook : _WORKBOOK;
  4.     workSheet : _WORKSHEET;
  5.     i,b,c: Integer;
  6. begin
  7.     try
  8.         barraProgreso.Min := 0;
  9.         i := 4;
  10.         //Columnas: Numero, Fecha, Duracion, Extension, Celular, Ent. o Sal., Usuario, Linea
  11.         workBook := Excel.Workbooks.Add(NULL,0);
  12.         workSheet := workBook.Sheets[1] as _WORKSHEET;
  13.         workSheet.Cells.Item[1,1].ColumnWidth := 2;
  14.         workSheet.Cells.Item[2,3]:='Reporte de llamadas realizadas.';
  15.         workSheet.Cells.Item[2,3].font.size:=16;
  16.  
  17.  
  18.         workSheet.Cells.Item[4,2] := 'Numero';
  19.         workSheet.Cells.Item[4,2].ColumnWidth := 30;
  20.         workSheet.Cells.Item[4,3] := 'Fecha';
  21.         workSheet.Cells.Item[4,3].ColumnWidth := 30;
  22.         workSheet.Cells.Item[4,4] := 'Duracion';
  23.         workSheet.Cells.Item[4,2].ColumnWidth := 10;
  24.         workSheet.Cells.Item[4,5] := 'Extension';
  25.         workSheet.Cells.Item[4,5].ColumnWidth := 10;
  26.         workSheet.Cells.Item[4,6] := 'Celular';
  27.         workSheet.Cells.Item[4,6].ColumnWidth := 20;
  28.         workSheet.Cells.Item[4,7] := 'Ent. o Sal. ';
  29.         workSheet.Cells.Item[4,7].ColumnWidth := 20;
  30.         workSheet.Cells.Item[4,8] := 'Usuario';
  31.         workSheet.Cells.Item[4,8].ColumnWidth := 10;
  32.         workSheet.Cells.Item[4,9] := 'Linea';
  33.         workSheet.Cells.Item[4,9].ColumnWidth := 13;
  34.  
  35.         max := DBGridDetalles.DataSource.DataSet.RecordCount;
  36.         ShowMessage(IntToStr(max));
  37.         barraProgreso.Max := max;
  38.         barraProgreso.Visible := true;
  39.  
  40.         with ZQDetalles do
  41.         begin
  42.             First;
  43.             while not EOF do
  44.             begin
  45.                 i := i + 1;
  46.                 workSheet.Cells.Item[i,2] := DBGridDetalles.Fields[0].AsString;
  47.                 Next;
  48.                 barraProgreso.StepIt;
  49.             end;
  50.         end;
  51.  
  52.         for b := 4 to i do
  53.         begin            Worksheet.Range['b'+IntToStr(b),'b'+IntToStr(b)].BorderAround(xlContinuous,xlTransparent,xlAutomatic,EmptyParam);            Worksheet.Range['c'+IntToStr(b),'c'+IntToStr(b)].BorderAround(xlContinuous,xlTransparent,xlAutomatic,EmptyParam);            Worksheet.Range['d'+IntToStr(b),'d'+IntToStr(b)].BorderAround(xlContinuous,xlTransparent,xlAutomatic,EmptyParam);            Worksheet.Range['e'+IntToStr(b),'e'+IntToStr(b)].BorderAround(xlContinuous,xlTransparent,xlAutomatic,EmptyParam);               Worksheet.Range['f'+IntToStr(b),'f'+IntToStr(b)].BorderAround(xlContinuous,xlTransparent,xlAutomatic,EmptyParam);            Worksheet.Range['g'+IntToStr(b),'g'+IntToStr(b)].BorderAround(xlContinuous,xlTransparent,xlAutomatic,EmptyParam);
  54.         end;
  55.         barraProgreso.Visible := false;
  56.     finally
  57.        Excel.Visible[1]:=true;
  58.     end;
  59. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement