您的位置:首页 > 编程语言

袁氏报表用代码画一个饼图

2007-06-13 16:45 363 查看
先要建一个ReportService.aspx 代码如下:

XDesigner.Report.ReportHtmlBuilder hb = this.Session["htmlbuilder"] as XDesigner.Report.ReportHtmlBuilder;
if (hb == null)
return;

if (this.Request.QueryString["imageindex"] != null)

if (this.Request.QueryString["out"] == "doc")
else if (this.Request.QueryString["out"] == "xls")
else if (this.Request.QueryString["out"] == "pdf")
else
hb.Save(this.Response.Output);

再建一个页面画大饼咯:

//先增一个报表
DesignReportDocument doc = new DesignReportDocument();
doc.Title = "动态报表";

//Lable
DesignReportLabel lbl = doc.CreateLabelElement();
lbl.Text = "动态报表演示";
lbl.TextColor = System.Drawing.Color.Yellow;
lbl.Font = new Font("宋体", 20, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
lbl.Align = StringAlignment.Center;
lbl.PrintDockStyle = PrintDockStyle.Top;
lbl.Height = 120;
lbl.Border.BackColor = Color.SkyBlue;
doc.Add(lbl);

//一个大饼
DesignReportPie pie = doc.CreatePieElement();
pie.Bounds = new Rectangle(169, 775, 1363, 954);
pie.Thickness = 60;
pie.BorderWidth = 1;
pie.LeftBorder = false;
pie.TopBorder = false;
pie.RightBorder = false;
pie.BottomBorder = false;
doc.Add(pie);

//增加列
for (int i = 1; i < 5; i++)

DesignReportLabelList reportpietext1 = doc.CreateLabelListElement();
doc.AppendChild(reportpietext1);
reportpietext1.ID = "reportpietext1";
reportpietext1.Bounds = new System.Drawing.Rectangle(215, 24, 1175, 731);
reportpietext1.BorderWidth = 1;
reportpietext1.ItemSpacing = 30;
reportpietext1.ItemHeight = 50;
reportpietext1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold);
reportpietext1.BarSize = 60;

XDesigner.Report.ReportBuilder rb = new ReportBuilder();
rb.LoadReport(doc);

XDesigner.Report.ReportHtmlBuilder hb = rb.CreateHtmlBuilder();
hb.ImgSrcFormatString = "reportservice.aspx?imageindex={0}";
hb.Refresh();
hb.ContentEncoding = this.Response.ContentEncoding;

this.Session["htmlbuilder"] = hb;
hb.Save(this.Response.Output);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐