We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
If you became a customer of the Syncfusion Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion for your reporting needs.

Implement Class Object List as Report Data source

Hi,
I am new to Syncfusion report and designer. I am trying to change the report framework in one of my project which is in ASP.NET Core MVC. I have a list of data that I use to get from entity framework code first. My class looks like below
public class Students{
public string Name{get;set;}
public int RollNo{get;set;}
public string ClassName{get;set;}
public List SubjectMarks{get;set;}
}
public class SubjectMarks{
public string SubjectName{get;set;}
public decimal FullMarks{get;set;}
public decimal PassMarks{get;set;}
public decimal ObtainedMarks{get;set;}
public List Activity{get;set;}
}
public class SubjectActivityMarks{
public string ActivityName{get;set;}
public decimal ObtainedMarks{get;set;}
}
So I would like to use generated object of above class combination in syncfusion report. Is it possible to use?
Also I tried to use web api data source data generated using above class object. But it throws json format required error. I manually browsed the web api path and copied the json data to validate in third party tool like jsonlint and there it shows json data is valid.
Could you please help me on both of the scenario?
Thanks
Pasang

3 Replies

VS Vinoth Srinivasan Syncfusion Team July 22, 2019 09:48 AM UTC

Hi Pasang, 
 
Thanks for your interest in Syncfusion components. 
 
Please find the below response for your queries. 
 
Query 
Response 
I am new to Syncfusion report and designer. I am trying to change the report framework in one of my project which is in ASP.NET Core MVC. I have a list of data that I use to get from entity framework code first. My class looks like below 
Yes, we can able to pass the local object model data for datasource in our ASP.NET Core ReportViewer application. Please find the below help documentation for how to use the local object model for datasource. 
 
We have prepared a simple sample in ASP.NET Core ReportViewer for your reference and it can be downloaded from below location. 
 
So I would like to use generated object of above class combination in syncfusion report. Is it possible to use? 
Could you please provide some additional details like how you are using our reporting control, whether you are using ReportViewer with ReportServer or without ReportServer at your end. It will be helpful for us to provide the solution at the earliest. 
Also I tried to use web api data source data generated using above class object. But it throws json format required error. I manually browsed the web api path and copied the json data to validate in third party tool like jsonlint and there it shows json data is valid. 
Could you please help me on both of the scenario? 
 
We were not able to find the exact root cause for this mentioned JSON data issue. So, could you please share your code snippet how you are specifying the data in web API. It is very useful to provide the solution earlier. 
 
 
Regards, 
Vinoth S. 



PT Pasang Tamang July 22, 2019 10:43 AM UTC

Hi,

Many thanks for your reply.

I am using Report Server to design report (rdl) file and goal is to use that rdl file in ASP.NET Core application. In my ASP.NET Core application I already have methods that returns data as expected in PDF form. Now I want to replace those PDF by Syncfusion ReportViewer. I have attached screenshot to have idea how my expected output is. 



Below is the API code I am using

    [Route("api/[controller]")]
    [ApiController]
    public class ExamReportController : ControllerBase
    {
[Route("GetMarksheet")]
[HttpGet]
public IActionResult GetMarksheet([FromQuery]int classId, [FromQuery]int sectionId, [FromQuery]int examId, [FromQuery]int schoolId, [FromQuery]int sessionId)
    {
var modelList = new List();
//my code to generate data and assign to modelList goes here
var finalModel = modelList.OrderBy(x => x.RollNo).ToList();
var datas = JsonConvert.SerializeObject(finalModel);
return Ok(datas);
    }
    }

Thanks

Regards,
Pasang


VS Vinoth Srinivasan Syncfusion Team July 25, 2019 06:47 AM UTC

Hi Pasang, 
 
Sorry for the delay. 
 
Please find the below response for your queries. 
 
Query 
Response 
I am using Report Server to design report (rdl) file and goal is to use that rdl file in ASP.NET Core application. In my ASP.NET Core application I already have methods that returns data as expected in PDF form. Now I want to replace those PDF by Syncfusion ReportViewer. I have attached screenshot to have idea how my expected output is.  
 
Yes, we can able to pass the local object model values for RDL report when setting the processing mode as local as shown in below code example. 
 
Index.cshtml: 
@{ 
    ViewData["Title"] = "ReportViewer ASP.NET CORE Support"; 
} 
<style> 
    body, html, #reportviewer { 
        overflow: hidden !important; 
        height: 100%; 
        width: 100%; 
    } 
</style> 
<sf-report-viewer id="reportviewer1" report-service-url="../Home" processing-mode="Local" /> 
<sf-script-manager></sf-script-manager> 
 
HomeController.cs: 
  public void OnInitReportOptions(ReportViewerOptions reportOption) 
        { 
            string basePath = _hostingEnvironment.WebRootPath; 
            FileStream reportStream = new FileStream(basePath + @"\Report\Region.rdl", FileMode.Open, FileAccess.Read); 
            reportOption.ReportModel.Stream = reportStream; 
 
            reportOption.ReportModel.DataSources.Clear(); 
            reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "StoreSales", Value = StoreSales.GetData() }); 
        } 
 
        public void OnReportLoaded(ReportViewerOptions reportOption) 
        { 
 
        } 
    } 
 
    public class StoreSales 
    { 
        public int SalesOrderID { get; set; } 
        public double TotalDue { get; set; } 
        public int CustomerID { get; set; } 
        public string Store { get; set; } 
        public string StateProvinceCode { get; set; } 
 
        public static List<StoreSales> GetData() 
        { 
            List<StoreSales> sales = new List<StoreSales>(); 
            StoreSales strSal = null; 
            strSal = new StoreSales() 
            { 
                SalesOrderID = 43659, 
                TotalDue = 23153.2339, 
                CustomerID = 29825, 
                StateProvinceCode = "GA", 
                Store = "Better Bike Shop" 
            }; 
 
We have prepared the simple sample for your reference and it can be downloaded from below location. 
Below is the API code I am using 
 
    [Route("api/[controller]")] 
    [ApiController] 
    public class ExamReportController : ControllerBase 
    { 
                            [Route("GetMarksheet")] 
                             [HttpGet] 
                             public IActionResult GetMarksheet([FromQuery]int classId, [FromQuery]int sectionId, [FromQuery]int examId, [FromQuery]int schoolId, [FromQuery]int sessionId) 
                  { 
                                           var modelList = new List(); 
                                            
                                           //my code to generate data and assign to modelList goes here 
                                            
                                           var finalModel = modelList.OrderBy(x => x.RollNo).ToList(); 
                                           var datas = JsonConvert.SerializeObject(finalModel); 
                                           return Ok(datas); 
                  } 
    } 
 
Based on your code snippet the Json data has been returned properly. So, it possible for you to modify the above sample to reproduce the issue at our end. 
 
 
Regards, 
Vinoth S. 


Loader.
Live Chat Icon For mobile
Up arrow icon