CSDN博客

img yuanqingfei

DELPHI版块RAVE报表上解决的问题(zz)

发表于2004/9/19 10:08:00  3475人阅读

 

我在DELPHI版块RAVE报表上解决的问题较多,而且发现提出的问题都有很大的相似性(本来提交了几个FAQ,但不知何时才能通过审核),所以就先整理一下自己的一点经验,希望能带给大家一点帮助,如果你觉得没什么用大可不必看.:)
以下的程序在XP+D6+Rave5.1下调试通过,
问题1:动态的设置报表中的内容
   uses
     RVClass, RVProj, RVCsStd; 
   var
     MyPage: TRavePage;
     MyText: TRaveText; 
   begin
     RaveProject1.Open;
     With RaveProject1.ProjMan do begin
       MyPage := FindRaveComponent('Report1.Page1',nil) as TRavePage; //查找PAGE
       MyText := FindRaveComponent('Text1',MyPage) as TRaveText; //查找TEXT
       MyText.Text := 'Boland Delphi'; //设置报表中文本内容
       MyText.Color := clGreen; //设置颜色
     end; { with }
     RaveProject1.ExecuteReport('Report1');
     RaveProject1.Close;
   end;

问题2:保存报表为HTML或PDF格式(对于PDF格式不支持中文)
   rvproject1.projectfile :='E:/delphi/rave/files/test.rav';
   rvproject1.Open;
   rvproject1.SelectReport('report1',true);//选择要打印的报表
   RvSystem1.DoNativeOutput:=false;
   RvSystem1.DefaultDest:= rdFile;//保存成文件
   RvSystem1.RenderObject:=RvRenderHTML1;//保存成HTML格式 或RPRenderPDF1;
   RvSystem1.OutputFileName:='files/test.html'; //存放的路径
   RvSystem1.SystemSetups:=RvSystem1.SystemSetups-[ssAllowSetup];
   try
      rvproject1.Execute;
   except
      ShowMessage('生成报表文件错误!');
   end;
   对于只有一页报表那是没有问题的,但对于多页在D6下和D7有所不同.D6下可以生成许多页,但D7下却
   不行,不知为什么?D6下的RAVE版本是5.1,
  
问题3: IntraWeb和Rave的无缝连接
       我的思路就是先把报表保存成HTML或PDF格式,然后再用IE调用
      const
          AIPOptions: string = 'toolbar=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,location=no,directories=no,width=1000,height=700';
      var
          aipurl :string;
      rvproject1.Open;
   rvproject1.SelectReport('report1',true);//选择要打印的报表
   RvSystem1.DoNativeOutput:=false;
   RvSystem1.DefaultDest:= rdFile;//保存成文件
   RvSystem1.RenderObject:=RvRenderHTML1;//保存成HTML格式
   RvSystem1.OutputFileName:='files/test.html'; //存放的路径
   RvSystem1.SystemSetups:=RvSystem1.SystemSetups-[ssAllowSetup];
   try
      rvproject1.Execute;//生成报表
      AIPURL := WebApplication.URLBase + '/files/' + 'test.html';  //IE打开第一页报表
         AddToInitProc('NewWindow("' + AIPURL + '", "Agenda", "' + AIPOptions+'");');
   except
      webapplication.ShowMessage('生成报表文件错误!');
   end; 

 问题4: 让最终用户动态的修改报表格式.
        with RvProject1 do
    begin
       DLLFile :='D:/Rave5/Redist/RaveSolo.dll'; //如果不指定此文件则运行时会报出错
       ProjectFile :='E:/delphi/rave/files/test.rav'; //指定RAV文件
       LoadDesigner :=true;
       If Design then begin
            If MessageDlg(Trans('Save changes to project ') +
                                ProjectFile + '?',
                                mtConfirmation,
                                [mbYes,mbNo,mbCancel],0) = mrYes then
            begin
              Save;//保存
            end; { if }
       end; { if }
    end;{with}
       此程序在D6+Rave5.1下调试通过.在D7下就用Rave.dll


问题5: 设计时通过程序动态向报表增加一个TEXT
        uses
        RVClass, RVProj, RVCsStd,RvCsRpt;
       
  var
    MyBand: TRaveBand;
    MyRegion: TRaveRegion;
    MyPage: TRavePage;
    MyText,mytext1: TRaveText;
  begin
    RvProject1.Open;
    With RvProject1.ProjMan do begin
        MyPage := FindRaveComponent('Report1.Page1',nil) as TRavePage;
        MyRegion:= FindRaveComponent('Region1',MyPage) as TRaveRegion;
        MyBand := FindRaveComponent('Band1',MyRegion) as TRaveBand;
        MyText:=TRaveText.Create(Myband);
        MyText.Parent:=Mypage;
        MyText.Name:=GetUniqueName('Text125',MyPage,false);
        MyText.Top:=0.2;
        MyText.Left:=0.7;
        MyText.Width:=200;
        MyText.Height:=200;
        MyText.Text:='Delphi';       
        MyText.Font.Size :=20;//设置字体的属性
        MyText.Font.Color :=ClRed;
        MyText.Font.Name :='隶书';
        AddComponent(MyText);
  
    end; { with }
    RvProject1.ExecuteReport('Report1');
    RvProject1.Close;
  
 问题6:在报表中插入日期或页数
      在RAVE设计时增加一个DATATEXT控件,其DATAFIELD属性有相关的设置
      Report Variables中有CurrentPage当前页,TotalPages总页数,DateShort短日期,DateLong长日期,
      TimeLong 长时间
     
 问题7:通过参数向报表传值,和问题1有点相同
      With RaveProject1 do begin
      Open;
      SetParam('ParamName','ParamValue');
      ExecuteReport('Report1');
      Close;
    end; { with }
   
  
问题8:去掉打印预览时出现的Output Options对话框
        RvSystem.SystemSetups中的ssAllowSetup 设为False
      
问题9:ndr格式转化为pdf
    var
    NDRStream: TMemoryStream;
  begin
    NDRStream := TMemoryStream.Create;
    try
      NDRStream.LoadFromFile('files/test.ndr');
      RvRenderPDF1.PrintRender(NDRStream, 'files/test.pdf');
    finally
      NDRStream.Free;
    end; { tryf }
    ShowMessage('NDR Converted');
  end;    
  
问题10: 分栏显示(snaking columns)
    name1     name6
    name2     name7
    name3     name8
    name4    
    name5     
    窗体添加以下控件Rvsystem1,table1,DataSource1 
    procedure TForm1.Button1Click(Sender: TObject);
  begin
    ReportSystem1.Execute;
  end;
  
  procedure TForm1.ReportSystem1Print(Sender: TObject);
  begin
    With (Sender as TBaseReport),Table1 do begin
      SetFont('Times New Roman', 20);
      Bold := True;
      Underline := True;
      Home;
      PrintCenter('NAME LISTING', PageWidth / 2.0);
      SectionTop := 1.0;
      MarginBottom := 0.75;
      Home;
      While not Table1.EOF do begin
        SetColumns(2,0.5);
        {OnNewColumn will be called after each call to SetColumns and on each
         new column after that}
  
        While (ColumnLinesLeft > 0) AND (NOT Table1.EOF) do begin
          If FieldByName('NAME').AsString <> '' then begin
            Println(FieldByName('NAME').AsString);
          end; {if}
          Table1.Next;
        end; {while}
  
        If not Table1.EOF then begin
          NewPage;
        end; {if}
      end; {while}
  
    end; { with }
  end;
  
  procedure TForm1.ReportSystem1BeforePrint(Sender: TObject);
  begin
    Table1.First;
  end;
  
  procedure TForm1.ReportSystem1NewColumn(Sender: TObject);
  begin
    With Sender as TBaseReport do begin
      SetFont('Times New Roman', 14);
      Bold := True;
      UnderLine := True;
      AdjustLine;
      Println(' NAME');
      SetFont('Arial',12);
      AdjustLine;
    end; {with}
  end;
  
  procedure TForm1.ReportSystem1PrintFooter(Sender: TObject);
  begin
    With  Sender as TBaseReport do begin
      MarginBottom := 0.5;
      PrintFooter('Page ' + Macro(midCurrentPage)
       + ' of ' + Macro(midTotalPages), pjCenter);
      MarginBottom := 0.75;
    end; {with}
  end;

问题11:通过rave面板中的textfiler把table中的内容直接打印到文本
       在窗体上增加table,textfiler,button;
  procedure TForm1.Button1Click(Sender: TObject);
  begin
   TextFiler1.FileName :='e:/rave/program/txtprint/tmp.txt';
    TextFiler1.Execute;
  end;
  
  procedure TForm1.TextFiler1Print(Sender: TObject);  
  var
    DoHeader: boolean;  
  begin
    With Sender as TBaseReport,Table1 do begin
      ClearTabs;
      SetTab(0.5,pjLeft,3.0,0,BOXLINENONE,0);
      SetTab(NA,pjLeft,3.0,0,BOXLINENONE,0);
      SetTab(NA,pjLeft,1.5,0,BOXLINENONE,0);
      First;
      DoHeader := true;
      While not EOF do begin
        If LinesLeft <= 0 then begin
          NewPage;
          DoHeader := true;
        end; { if }
        If DoHeader then begin
          PrintCenter('Customer Listing',PageWidth / 2.0);
          NewLine;
          NewLine;
          PrintTab('name');
          PrintTab('sex');
          PrintTab('age');
          NewLine;
          DoHeader := false;
        end; { if }
        PrintTab(FieldByName('name').AsString);
        PrintTab(FieldByName('sex').AsString);
        PrintTab(FieldByName('age').AsString);
        NewLine;
        Next;
      end; { while }
    end; { with }
  end;
  
问题12:设计好的Rave报表文件如何打包到EXE文件中
    在rvproject的属性中有一个storerav,你只要load .rav文件即可

问题13:格式化字符串
    对于从数据源取出的字段如何格式化如price 在表中12345.25现要显示为$12,345.2500
       只需在设计时修改Data View Dictionary->dataview1->dataviewprice中的displayFormat为
        $#,####,###.0000;

问题14:常常要USES到的单元   
  RvCsStd :TRaveText,TRaveMemo,TRaveSection,TRaveSection,TRaveMetaFile,
         TRaveFontMaster,TRavePageNumInit
              
RvClass:TRaveComponent,TRaveControl, TRaveContainerControl,
        TRaveContainerComponent,TRaveProjectItem,TRavePage        
           
RvCsData:TRaveDataText,TRaveDataMemo,TRaveCalcText,
 TRaveDataMirrorSection,TRaveDataCycle,    TRaveCalcOp,TRaveCalcTotal,TRaveCalcController    
   
RvCsBars: TRavePostNetBarCode,TRaveI2of5BarCode,TRaveCode39BarCode,TRaveCode128BarCode,TRaveUPCBarCode,TRaveEANBarCode         

RvCsDraw: TRaveLine,TRaveHLine,TRaveVLine,TRaveRectangle,
            TRaveSquare,TRaveEllipse, TRaveCircle      
    
RvDataField: TRaveStringField,TRaveIntegerField,
     TRaveBooleanField,TRaveFloatField,TRaveCurrencyField,TRaveBCDField,
     TRaveDateField,TRaveTimeField,TRaveDateTimeField,TRaveBlobField,
     TRaveMemoField,TRaveGraphicField,TRaveInt64Field
    
RvDatabase: TRaveDatabase


RvDirectDataView: TRaveDataView
                  TRaveDriverDataView
                 
RvProj:TRaveReport,TRaveProjectManager

RvSecurity:TRaveSimpleSecurity,TRaveLookupSecurity


RvCsRpt:TRaveRegion,TRaveBand,TRaveDataBand,TRaveIterateBand,
TRaveBandStyle,TRaveDataCycle,
  
 部分资料来源于RAVE开发人员指南 ravedevguide5
 新闻组News.Nevrona.com
 RAVE的官方主页 www.nevrona.com/rave


问题16:打印JPEG
法一:在RAVE上增加JPEG控件
 Bitmap components can only display bitmaps, not jpegs.  You'll need the jpeg
add-on that's available from the Nevrona web site,
http://www.nevrona.com/rave/addons.shtml.

  Installation instructions for TRaveJPEGImage
--------------------------------------------

1: Extract the files in this archive in your Rave main directory
(normally d:/RAVE5).  Make sure to expand with directories so that the source
will be placed in it's own directory.

2: Copy the NDCsJPEG.PAS file into the appropriate directory for the version
of Delphi or C++Builder that you are using (for Delphi 6.0 it would normally
be d:/RAVE5/D6).

3: Start Rave, go to the preferences dialog (Edit|Preferences), select the
Packages tab and add the D:/RAVE5/ND_JPEG.BPL package file to the list of
installed package and click OK.

法二,程序中控制,具体参照//www.nevrona.com/rave/tips/rvtip31.html

0 0

相关博文

我的热门文章

img
取 消
img