Imprimir
31/10/2003
0
Eu tenho duas funções onde imprime o conteúdo de um StringGrid. Eu tenho tb mais dois StringGrid que fiz de cabeçalho e gostaria de imprimi-los tb, mas ja tentei n possibilidades e não dá certo, será que vc consegue me ajuda?
A primeira procedure Imprime direto para impressora
A segunda imprime para aquivo
Gostaria de fazer isso nas duas procedures
Imprimir cabecalho1 + Cabecaho2 + Conteudo (Todos são do tipo StringGrid)
[/code]
A primeira procedure Imprime direto para impressora
A segunda imprime para aquivo
Gostaria de fazer isso nas duas procedures
Imprimir cabecalho1 + Cabecaho2 + Conteudo (Todos são do tipo StringGrid)
procedure PrintGrid(sGrid: TStringGrid; sTitle : string); var X, Y, Lin, Col : Integer; TR : TRect; cab1 : string; begin //Titulo Printer.Orientation := poPortrait; Printer.Title := sTitle; Printer.Orientation := poPortrait; Printer.BeginDoc; Printer.Canvas.Pen.Color := 0; Printer.Canvas.Font.Name := ´MS Sans Serif´; Printer.Canvas.Font.Size := 8; Printer.Canvas.TextOut(0, 100, Printer.Title ); // Percorre cada coluna for Col := 0 to sGrid.ColCount - 1 do begin // Identifica as coordenadas (X,Y) da coluna de acordo com a largura da // mesma, conforme o Grid. X := 0; for Lin := 0 to (Col - 1) do X := X + 5 * (sGrid.ColWidths[Lin]); // Imprime cada linha da coluna. for Lin := 1 to sGrid.RowCount - 1 do begin // Define as corrdenadas (X,Y) e uma área Retangular Y := 150 * Lin + 300; TR := Rect(X, Y, X2 - 1, Y2); // Se for a primeira coluna (0) põe fundo cinza if Col = 0 then Printer.Canvas.Brush.Color := clLtGray else Printer.Canvas.Brush.Color := clWhite; // Imprime o conteúdo da célula (TextRect) e a borda da célula (FrameRect) Printer.Canvas.TextRect(TR, X1 + 50, Y1 + 50, sGrid.Cells[Col, Lin - 1]); Printer.Canvas.Brush.Color := clBlack; Printer.Canvas.FrameRect(TR); Printer.Canvas.Brush.Color := clWhite; end; end; Printer.EndDoc; end; //----------------------------------------------------------------------------- procedure SaveGridToFile(Grid, Grid2: TStringGrid; const Filename: String); var I, J : Integer; Text : TextFile; Widths : array of Integer; TotalWidth : Integer; begin AssignFile(Text, Filename); Rewrite(Text); try SetLength(Widths, Grid.ColCount); TotalWidth := 0; for I := 0 to Grid.ColCount - 1 do begin Widths[I] := 0; for J := 0 to Grid.RowCount - 1 do begin if Length(Grid.Cells[I, J]) > Widths[I] then Widths[I] := Length(Grid.Cells[I, J]); end; Inc(Widths[I], 2); Inc(TotalWidth, Widths[I]); end; for I := 0 to Grid.RowCount - 1 do begin if I <> 0 then begin for J := 0 to TotalWidth + Length(Widths) + 3 do Write(Text, ´-´); Write(Text, 1310); end; for J := 0 to Grid.ColCount - 1 do begin if J <> 0 then Write(Text, ´ |´); Write(Text, Grid.Cells[J, I]:Widths[J]); end; Write(Text, 1310); end; finally CloseFile(Text); end; end;
Marcela
Curtir tópico
+ 0
Responder
Posts
Clique aqui para fazer login e interagir na Comunidade :)