先要建一个ReportService.aspx 代码如下:
XDesigner.Report.ReportHtmlBuilder hb
=
this
.Session[
"
htmlbuilder
"
]
as
XDesigner.Report.ReportHtmlBuilder;
if
(hb
==
null
)
return
;

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

{
System.Drawing.Imaging.ImageFormat f = System.Drawing.Imaging.ImageFormat.Png;

string imagType = this.Request.QueryString["imagetype"];
if (imagType == "jpg")
f = ImageFormat.Jpeg;

hb.SaveReportImage(
Convert.ToInt32(this.Request.QueryString["imageindex"]),
this.Response.OutputStream,
f);
return;
}

if
(
this
.Request.QueryString[
"
out
"
]
==
"
doc
"
)

{
// Output MS Word 2000 document
hb.SaveWordDocument(this.Response.OutputStream);
this.Response.ContentType = "application/msword";
//this.Response.AppendHeader("Content-Disposition","attachment;filename=" + System.Web.HttpUtility.UrlEncode( hb.Title ) + ".doc");
}
else
if
(
this
.Request.QueryString[
"
out
"
]
==
"
xls
"
)

{
// Output MS Excel2000 document
hb.SaveExcelDocument(this.Response.OutputStream);
this.Response.ContentType = "application/vnd.ms-excel";
//this.Response.AppendHeader("Content-Disposition","attachment;filename=" + System.Web.HttpUtility.UrlEncode( hb.Title ) + ".xls");
}
else
if
(
this
.Request.QueryString[
"
out
"
]
==
"
pdf
"
)

{
hb.SavePDFDocument(this.Response.OutputStream);
this.Response.ContentType = "application/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
++
)

{
DesignReportPieItem pieItem = doc.CreatePieItemElement();
pieItem.ID = "pieItem" + i;
pieItem.Value = i.ToString();
pieItem.Text = i.ToString() + "_" + i.ToString();
pieItem.FillColor = System.Drawing.Color.FromArgb((i * 1000) % 255, (i * 100) % 255, (i * 10) % 255);
//pieItem.BackColor = System.Drawing.Color.FromArgb(255, 255, (i * 100) % 255);
pie.AppendChild(pieItem);
}

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);