作成日: 2016/06/01 最終更新日: 2016/06/01
文書種別
使用方法
詳細
コードビハインドで動的にレポート(C1Report)を作成するには、次のように設定します。
◎サンプルコード (C#)
- プロジェクトにC1.C1Report.4.dllアセンブリへの参照を追加します。
- C1Reportインスタンスを返却する静的メソッドを実装する、静的クラスを定義します。
- C1ReportViewer.RegisterDocumentクラスメソッドを実行して、第1引数に適当なレポート名を、第2引数に2.で定義した静的メソッドを指定します。
- C1ReportViewer.FileNameプロパティに、3.の第1引数で指定したレポート名を設定します。
Imports C1.C1Report
Imports C1.Web.Wijmo.Controls.C1ReportViewer
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
C1ReportViewer.RegisterDocument("MyReport", AddressOf MyReport.CreateReport)
C1ReportViewer1.FileName = "MyReport"
End Sub
End Class
Public Class MyReport
Public Shared Function CreateReport() As C1Report
Dim dt As New DataTable()
:
Dim rep As C1Report = C1ReportViewer.CreateC1Report()
rep.Load(HttpContext.Current.Server.MapPath("~") & "○○○.xml", "○○○")
rep.DataSource.Recordset = dt
Return rep
End Function
End Class
Imports C1.Web.Wijmo.Controls.C1ReportViewer
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
C1ReportViewer.RegisterDocument("MyReport", AddressOf MyReport.CreateReport)
C1ReportViewer1.FileName = "MyReport"
End Sub
End Class
Public Class MyReport
Public Shared Function CreateReport() As C1Report
Dim dt As New DataTable()
:
Dim rep As C1Report = C1ReportViewer.CreateC1Report()
rep.Load(HttpContext.Current.Server.MapPath("~") & "○○○.xml", "○○○")
rep.DataSource.Recordset = dt
Return rep
End Function
End Class
◎サンプルコード (C#)
using System.Data;
using C1.C1Report;
using C1.Web.Wijmo.Controls.C1ReportViewer;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
C1ReportViewer.RegisterDocument("MyReport", MyReport.CreateReport);
C1ReportViewer1.FileName = "MyReport";
}
}
public class MyReport
{
public static C1Report CreateReport()
{
var dt = new DataTable();
:
C1Report rep = C1ReportViewer.CreateC1Report();
rep.Load(HttpContext.Current.Server.MapPath("~") + "○○○.xml", "○○○");
rep.DataSource.Recordset = dt;
return rep;
}
}
using C1.C1Report;
using C1.Web.Wijmo.Controls.C1ReportViewer;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
C1ReportViewer.RegisterDocument("MyReport", MyReport.CreateReport);
C1ReportViewer1.FileName = "MyReport";
}
}
public class MyReport
{
public static C1Report CreateReport()
{
var dt = new DataTable();
:
C1Report rep = C1ReportViewer.CreateC1Report();
rep.Load(HttpContext.Current.Server.MapPath("~") + "○○○.xml", "○○○");
rep.DataSource.Recordset = dt;
return rep;
}
}
関連情報
旧文書番号
74526