Form1上有StringGrid1和Button1;如何完成点击Button1后预览StringGrid1的打印内容;
预览窗口调用FastReport设计器的那个预览窗口;
当StringGrid1内容多时实现能自动分页。请给出简单处理思路和简单示例代码。
QuickReport可以完成相同功能也可以。请各位帮帮小弟。
谢谢!

解决方案 »

  1.   

    直接用报表工具实现难度较大,主要是纸张的大小控制不好,列数一多容易超过纸张的边界,而QuickRep对中文的自动换行功能好像支持不好,因此可以考虑输出到Excel中,在进行报表的排版等工作
    http://expert.csdn.net/Expert/topic/1105/1105886.xml?temp=.5982935 
    我一般也是这么做的
      

  2.   

    建议输出到Word or Excel现在的甲方个性化要求多的是
    用office作为输出工具
    他们方便
    你也舒服采用OLE+VBA
      

  3.   

    谢谢两位的建议。我纯属为了学习FastReport的用法而已。
    可否给个FastReport的简单例子?
      

  4.   

    FASTREPORT里不是有直接打印STRINGGRID的控件吗,直接打印就可以了
      

  5.   

    to snjun(@军军@):
    我用的是delphi 5.
    直接打印StringGrid的控件是哪个呢?
    也找不到PrnGrid这个例子。
      

  6.   

    用FastReport打印StringGrid比较麻烦一点,什么都要自己控制。报表格式你可以看Report的Demo,有一个Cross-tab的例子。但是还要在Form中的TfrReport控件几个事件中写一些代码。
    1、OnBeforePrint
    2、OnGetValue
    3、OnPrintColumn我这里写了一些是我程序中用到的,你可以借鉴一下。
    procedure TfrmTrack.frReport1BeforePrint(Memo: TStringList; View: TfrView);
    begin
    //这里设置打印的宽度以及打印的边框格式
      View.dx := FWidth;
      if View.Name='Memo1' then
      begin
        Case ColDataSet.RecNo of
          0:FFrameTyp:=15;
          1,2:FFrameTyp:=14;
          3,4,5:FFrameTyp:=10;
          6:FFrameTyp:=11;
        end;
        if ColDataSet.RecNo>5 then
        begin
          if (ColDataSet.RecNo) Mod 3 =0 then
            FFrameTyp:=14;
          if (ColDataSet.RecNo-1) Mod 3 =0 then
            FFrameTyp:=10;
          if (ColDataSet.RecNo-2) Mod 3 =0 then
            FFrameTyp:=11;
        end;
        View.FrameTyp:=FFrameTyp;
      end;
    end;
    procedure TfrmTrack.frReport1GetValue(const ParName: String;
      var ParValue: Variant);
    begin
    //下面是从StringGrid取值
      if AnsiCompareText(ParName, 'isClip') = 0 then
        if sUpDown='1' then
          ParValue := 'FCLIP'
        else
          ParValue := 'FCVP';  if AnsiCompareText(ParName, 'Cell') = 0 then
      begin
        frReport1.Dictionary.Variables['MyRow']:=RowDataset.RecNo;
        frReport1.Dictionary.Variables['MyCol']:=ColDataset.RecNo;
        if sUpDown='1' then
        begin
          ParValue := sgrdFClip.Cells[ColDataset.RecNo, RowDataset.RecNo];
        end
        else
        begin
          ParValue := sgrdMain.Cells[ColDataset.RecNo, RowDataset.RecNo];
        end;
      end;
    end;procedure TfrmTrack.frReport1PrintColumn(ColNo: Integer; var Width: Integer);
    begin
    //这里控制打印宽度
      if sUpDown='1' then
        width:=sgrdFclip.ColWidths[colNo-1]
      else
        width:=sgrdMain.ColWidths[colNo-1];
      fWidth:=width;
      Inherited;  
    end;