在 Web 中,您可以先创建业务对象的描述,然后创建报表模板,然后将数据源与真实数据连接并呈现报表。创建业务对象的描述。注意!:您必须使业务对象的类与 .NET 中的业务对象类相同
DBEntities entity = new DBEntities();
List<Section> result = entity.Sections.ToList();
StiReport report = new StiReport();
report.RegBusinessObject("Section",result);
int busobjLevel = 1;
report.Dictionary.SynchronizeBusinessObjects(busobjLevel);
//in web you should call design with parameter like this
StiWebDesigner1.Design(report);
用于显示报告:创建报告模板后,您可以将其保存,例如保存到以下路径 D:\myReport.mrt。由于业务对象的描述不包含实际数据,为了构建报表,您应该获取业务对象的真实数据
int busobjLevel = 1;
StiReport report = new StiReport();
report.Load("D:\\myReport.mrt");
using (DBEntitiescontext = new DBEntities())
{
var result = entity.Sections.ToList();
report.RegBusinessObject("Sections", result);
StiWebViewer1.Report = report;
}