簡體   English   中英

Delphi Rave報告生成空白頁

[英]Delphi Rave Report generating blank page

我在Rave Reports 10上有一些經驗,我過去曾經做過很多報告,但是現在我對它的生成有疑問。

清單:在主窗體上-RvProject -RvSystem -RvDataSet -RvRenderPDF

他們都成立了

在Rave Designer上,我可以成功生成報告,但是當我使用代碼時,它將生成空白頁。

您能檢查我的代碼並告訴我是否缺少什么嗎? 自兩天前以來,我就一直呆在這個陡峭的地方,無法解決這個問題。

我知道有很多不用的變量,但是我嘗試了一些事情。

procedure TFormPrincipal.ImprimirReporteDeNomina(FechaCorte:String);
var
  DireccionMisDocumentos,A:String;
  Año, Mes, Dia:Word;
  I:Integer;
  MyFields: array of TField;
  Temf: TStringField;
  DataView: TRaveBaseDataView;
  myPage:TRavePage;
  MyDataText:TRaveDataText;
  MyText:TRaveText;
  //MyPage2:TRavePage;
  nMarginBottom, nMarginLeft, nMarginRight, nMarginTop: Double;
begin
  with RvProject1 do
    begin
      SetLength(FechaCorte,10);

      //A:=GetCurrentDir()+'\Data\NOMREP1.rav';
      //ProjectFile:=GetCurrentDir()+'\Data\NOMREP1.rav';
      //Open;
      //LoadFromFile(GetCurrentDir()+'\Data\NOMREP1.rav');
      //StoreRAV:=True;
      //ZQuery2.Fields.Clear;
      ZQuery2.Close;
      ZQuery2.SQL.Clear;
      ZQuery2.SQL.Add('Select');
      ZQuery2.SQL.Add('NumeroEmpleado,');
      ZQuery2.SQL.Add('Cargo,');
      ZQuery2.SQL.Add('Nombre,');
      ZQuery2.SQL.Add('Apellido,');
      ZQuery2.SQL.Add('Format(Cedula,0),');
      ZQuery2.SQL.Add('Ingreso,');
      ZQuery2.SQL.Add('Format(SalarioMensual,2),');
      ZQuery2.SQL.Add('Format(SalarioDiario,2),');
      ZQuery2.SQL.Add('Format(CTDiario,2),');
      ZQuery2.SQL.Add('DiasTrabajados,');
      ZQuery2.SQL.Add('DiasLibres,');
      ZQuery2.SQL.Add('CT,');
      ZQuery2.SQL.Add('Ausencias,');
      ZQuery2.SQL.Add('Format(SSO,2),');
      ZQuery2.SQL.Add('Format(RPE,2),');
      ZQuery2.SQL.Add('Format(FAOV,2),');
      ZQuery2.SQL.Add('Format(TotalSueldo,2),');
      ZQuery2.SQL.Add('Format(TotalSanciones,2),');
      ZQuery2.SQL.Add('Format(TotalCT,2),');
      ZQuery2.SQL.Add('Format(TotalDiasLibres,2),');
      ZQuery2.SQL.Add('Format(TotalAusencias,2),');
      ZQuery2.SQL.Add('Format(TotalAsignaciones,2),');
      ZQuery2.SQL.Add('Format(TotalDeducciones,2),');
      ZQuery2.SQL.Add('Format(TotalCobrar,2)');
      ZQuery2.SQL.Add('From Constructor.ZRepNom');
      //ZQuery2.Open;
      //ZQuery2.Close;

      {
      SetLength(MyFields, ZQuery2.FieldDefs.Count);
      //Add one by one the fields to make them accesible.
      for i:=0 to ZQuery2.FieldDefs.Count - 1 do
        MyFields[i] := ZQuery2.FieldDefs[i].CreateField(ZQuery2);
      //Create all Calculated Fields as you need
      Temf := TStringField.Create(nil);
      Temf.FieldKind := fkCalculated;
      //Temf.FieldName := 'NewCalcField';
      }
      Open;

      With ProjMan do
        begin
          Dataview := FindRaveComponent('DataView1',nil) as TRaveBaseDataView;
          CreateFields(DataView, nil, nil, true); // refresh the dataview
        end;

      With ProjMan do
        begin
          MyPage := FindRaveComponent('Report1.Page1',nil) as TRavePage;
          MyText := FindRaveComponent('FECHACORTE',MyPage) as TRaveText;
          MyText.Text:=FechaCorte;
        end; { with }

      Save;
      {
      with IACProyectUnidades.ProjMan do
        begin
          nMarginBottom := 0.5;
          nMarginLeft := 0.5;
          nMarginRight := 0.5;
          nMarginTop := 0.5;
        end;
        }
      //seleccionamos el printer por defecto,
      //asi salen los reportes tal cual queremos
      //desde cualquier maquina con cualquier impresora
      RpDev.SelectPrinter('microsoft xps document writer', False );
      DireccionMisDocumentos:=GetMyDocuments;
      if Not (DirectoryExists(DireccionMisDocumentos+'\Informes Luminatti\Nomina')) then
        CreateDir(DireccionMisDocumentos+'\Informes Luminatti\Nomina');
      //Label4.Caption:= 'Generando Reporte...';
      RvSystem1.DefaultDest := rdFile;
      RvSystem1.DoNativeOutput := false;
      RvSystem1.RenderObject := RvRenderPDF1;
      RvSystem1.OutputFileName := DireccionMisDocumentos+'\Informes Luminatti\Nomina\['+NOMREPMes.Text+' '+FechaCorte+']Reporte de Nómina.pdf';
      RvSystem1.SystemSetups := RvSystem1.SystemSetups - [ssAllowSetup];
      //ZConnection1.Connected:=False;
      RvSystem1.Execute;
      //Label4.Caption:= 'Reporte Generado!';
      ShellExecute(FormPrincipal.Handle,nil,PChar(DireccionMisDocumentos+'\Informes Luminatti\Nomina\['+NOMREPMes.Text+' '+FechaCorte+']Reporte de Nómina.pdf'),'','',SW_SHOWMAXIMIZED);
    end;
end;

我終於發現了錯誤,是一個寫作錯誤

錯誤是: RvSystem1.Execute;

正確的方法是: RvProject1.Execute;

解決了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM