I am tying to implement JasperReport in ASP.Net and its showing missing JasperReports dll.
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using JasperReports.Data;
using JasperReports.Engine;
using JasperReports.Engine.Data;
using JasperReports.Engine.Export.Html;
using JasperReports.Engine.Query;
using JasperReports.Engine.Util;
using JasperReports.Engine.Xml;
namespace JasperReportsDemo
{
class Program
{
static void Main(string[] args)
{
// Define the JasperReport Server URL and credentials
string serverUrl = "http://xxx.xx.x.xx:8080/jasperserver";
string username = "abc";
string password = "abc";
// Define the report template path
string reportPath = "/reports/SalesReport.jrxml";
// Define the report parameters
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("StartDate", DateTime.Now.AddDays(-30));
parameters.Add("EndDate", DateTime.Now);
// Define the report data source
DataTable salesData = new DataTable("SalesData");
salesData.Columns.Add("SalesDate", typeof(DateTime));
salesData.Columns.Add("SalesPerson", typeof(string));
salesData.Columns.Add("Product", typeof(string));
salesData.Columns.Add("Quantity", typeof(int));
salesData.Columns.Add("Price", typeof(double));
for (int i = 1; i <= 100; i++)
{
salesData.Rows.Add(new object[] {
DateTime.Now.AddDays(-i),
"Sales Person " + i,
"Product " + i,
i * 10,
i * 100
});
}
// Create the report data source
JRDataSource dataSource = new JREmptyDataSource();
dataSource = new JRBeanCollectionDataSource(salesData);
// Generate the report output
JasperPrint report = JasperFillManager.FillReport(reportPath, parameters, dataSource, new JdbcConnectionProvider(serverUrl, username, password));
// Export the report to HTML
HtmlExporter exporter = new HtmlExporter();
exporter.ExportReport(report, new MemoryStream());
string htmlData = exporter.GetHtmlContent();
}
}
}
1 Answer:
Hi Vikkumarash, it sounds like you are trying to use a JasperReports (which is a java library) with C# (.NET). This will not work.
An option to use JasperReports with a non-java project is to use JasperReports IO e its REST Api.
https://community.jaspersoft.com/project/jasperreports-io
Thank you
Giulio
Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times.