This example shows how to use business objects in the report. First, load scripts:
@using Stimulsoft.Base
@using Stimulsoft.Report
@using Stimulsoft.Report.Blazor
@using Stimulsoft.Report.Web

Next, add report designer:
<StiBlazorDesigner Report="@Report" OnSaveReport="@OnSaveReport" />

After that, create empty report object and load report template:
@code
{
	//Report object to use in designer
	private StiReport Report;

	protected override async Task OnInitializedAsync()
	{
		await base.OnInitializedAsync();

		//Create empty report object
		this.Report = new StiReport();

		//Load report template
		var reportBytes = await Http.GetByteArrayAsync("Reports/BusinessObjects.mrt");
		this.Report.Load(reportBytes);

...

Then, create and register business object:
...

		//Create business object
		var list = GetBusinessObject();

		//Register business object in the report template
		this.Report.RegBusinessObject("MyList", list);
		this.Report.Dictionary.Synchronize();
	}

...

Next, create save method:
...

    private void OnSaveReport(StiSaveReportEventArgs args)
    {
  		var reportJson = args.Report.SaveToJsonString();
		
		await Task.CompletedTask;
    }


...

Finally, fill data to business objects:
...

	//Business objects
    public class BusinessEntity
    {
        public string Name { get; set; }

        public string Alias { get; set; }

        public BusinessEntity(string name, string alias)
        {
            Name = name;
            Alias = alias;
        }
    }

    private System.Collections.ArrayList GetBusinessObject()
    {
        var list = new System.Collections.ArrayList();
        list.Add(new BusinessEntity("name1", "alias1"));
        list.Add(new BusinessEntity("name2", "alias2"));
        list.Add(new BusinessEntity("name3", "alias3"));

        return list;
    }
}

Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

Using Business Objects in the Report

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.