0

我想将 Session[CountryList"] 用于数据源报告图表。

我将图表添加到报告中,但是没有代码。

如何将 Session[CountryList"] 添加为数据源并将其显示在我的报告图表中?

模型:

public static IList<Country> GetCountries()
{
return new List<Country>(){
new Country("Russia", 50),
new Country("Canada", 231),
new Country("USA", 33),
new Country("China", 111),
new Country("Brazil", 14),
new Country("Australia", 140),
new Country("India", 434),
new Country("Turkey", 3),
new Country("England", 21),
new Country("Greece", 116)
};
}
}
public class Country
{
string name;
double area;
public string Name { get { return name; } }
public double Area { get { return area; } }
public Country(string name, double area)
{
this.name = name;
this.area = area;
}
}

控制器:

public ActionResult ReportViewerPartial()
{

Session["CountriesDatas"] = CountriesProvider.GetCountries(); //Country List

XtraReport1 report = new Q502351.Reports.XtraReport1();
report.DataSourceDemanded += report_DataSourceDemanded;
ViewData["Report"] = report;
return PartialView("ReportViewerPartial");
}
4

1 回答 1

0

我尝试使用您的模型数据。

下面的代码也适用于您。

public ActionResult ExportReportViewer()
{
XtraReport1 report = new CrmSoner.Reports.XtraReport1();
XRChart chart = report.FindControl("xrChart1", true) as XRChart;
List<Country> list = Session["CountriesDatas"] as List<Country>;
chart.DataSource = list;
chart.Series[0].ArgumentDataMember = "Name";
chart.Series[0].ValueDataMembers.Clear();
chart.Series[0].ValueDataMembers.AddRange(new string[] { "Area" });

return DevExpress.Web.Mvc.ReportViewerExtension.ExportTo(report);
}
于 2013-09-21T09:55:59.587 回答