クリスタルレポートを埋め込むには?

解決


fujiken  2008-04-29 15:08:20  No: 30607

初めまして。fujikenと申します。
ヘルプを見ながら、
ReportDocument にロードされる埋め込みでない Report クラスへのバインド
に取り組んでいます。

Delphi for .NetプロジェクトからWinフォームを選択して、
WinFormでは CrystalReportViewer を貼り付け、
Dockプロパティもヘルプに倣い、Fillに設定してあります。

なぜかmyReportDocument.Load(reportPath); の Load 部分で赤い波線が
でていますが、
この状態で実行すると、
「プロセスを生成できません。」のエラーが発生してしまいます。
どこが原因なのか分からないのです。

どなたかお教えいただけませんでしょうか。
宜しくお願いします。

WinXP Pro
Delphi2005(updateはしていません)を使っています。
レポート World Sales Report.rpt は
Delphiからのデザイン画面(?)でフィールドの確認が出来ます。
長くなりますがそのままのコードです。

unit WinForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, CrystalDecisions.Windows.Forms,
  CrystalDecisions.CrystalReports.Engine, CrystalDecisions.Shared;

type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION 'デザイナ管理コード'}
  strict private
    /// <summary>
    /// 必要なデザイナ変数です。
    /// </summary>
    Components: System.ComponentModel.Container;
    myCrystalReportViewer: CrystalDecisions.Windows.Forms.CrystalReportViewer;
    /// <summary>
    /// デザイナサポートに必要なメソッドです。
    /// このメソッドの内容をコードエディタで変更しないでください。
    /// </summary>
    procedure InitializeComponent;
  {$ENDREGION}
  strict protected
    /// <summary>
    /// 使用されているリソースの後処理を実行します。
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private 宣言 }
    procedure ConfigureCrystalReports;

  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]

implementation

{$AUTOBOX ON}

{$REGION 'Windows フォームデザイナが生成したコード'}
/// <summary>
/// デザイナサポートに必要なメソッドです。
/// このメソッドの内容をコードエディタで変更しないでください。
/// </summary>
procedure TWinForm.InitializeComponent;
begin
  Self.myCrystalReportViewer := CrystalDecisions.Windows.Forms.CrystalReportViewer.Create;
  Self.SuspendLayout;
  // 
  // myCrystalReportViewer
  // 
  Self.myCrystalReportViewer.ActiveViewIndex := -1;
  Self.myCrystalReportViewer.Dock := System.Windows.Forms.DockStyle.Fill;
  Self.myCrystalReportViewer.Location := System.Drawing.Point.Create(0, 0);
  Self.myCrystalReportViewer.Name := 'myCrystalReportViewer';
  Self.myCrystalReportViewer.ReportSource := nil;
  Self.myCrystalReportViewer.Size := System.Drawing.Size.Create(624, 472);
  Self.myCrystalReportViewer.TabIndex := 0;
  // 
  // TWinForm
  // 
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(7, 15);
  Self.ClientSize := System.Drawing.Size.Create(624, 472);
  Self.Controls.Add(Self.myCrystalReportViewer);
  Self.Name := 'TWinForm';
  Self.Text := 'WinForm';
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm.Create;
begin
  inherited Create;
  //
  // Windows Form デザイナのサポートに必要です。
  //
  InitializeComponent;
  //
  // TODO: InitializeComponent 呼び出しの後のコンストラクタコードを追加
  //
  ConfigureCrystalReports;
end;

procedure TWinForm.ConfigureCrystalReports;
var
  reportPath : String;
  myReportDocument : ReportDocument;
begin
  reportPath :=
    '$(Root Borland Delphi 2005)\Demos'
    + '\Crystal Reports\Reports\General Business'
    + '\World Sales Report.rpt';
  myReportDocument := ReportDocument.Create;
  myReportDocument.Load(reportPath);

  myCrystalReportViewer.ReportSource := myReportDocument;

end;

end.


fujiken  2008-04-29 15:19:13  No: 30608

ごめんなさい。タイトルが逆です。
埋め込まないクリスタルレポートについてでした。


fujiken  2008-05-02 13:23:14  No: 30609

とりあえずレポートプレビューが表示出来るようになりましたので
報告です。
1)出てくるエラーに不思議さを感じ、ホームディレクトリから
プロジェクトを作り直し。
2)Loadメソッドを使わず、直接CrystalReportViewer コントロールを
バインドする。
この二つで何とか表示できるようになりました。


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加