4,816
社区成员
发帖
与我相关
我的任务
分享
using DetectionOfCadmiumRice.Parament;
using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
using System.Drawing;
namespace XtraReportsDemos.PivotGridAndChart
{
public partial class OverproofReportBlind : XtraReport {
private int bindCount = 0;
private int FieldIndex = 0;
private int adder = 0;
public OverproofReportBlind() {
InitializeComponent();
for (int i = 0; i < xrPivotGrid1.Fields.Count; i++)
{
xrPivotGrid1.Fields[i].Width = (PageWidth - Margins.Left - Margins.Right) / xrPivotGrid1.Fields.Count;
}
}
private void xrPivotGrid1_PrintCell(object sender, DevExpress.XtraReports.UI.PivotGrid.CustomExportCellEventArgs e)
{
if (!e.Value.ToString().Contains("Total"))
{
if (((ReportData)DataSource).Blind.Count > bindCount && ((ReportData)DataSource).Blind[bindCount].AnalysisElement[FieldIndex].Comment == "超标")
{
//if (e != null && e.Value != null && e.Value.ToString() == "超标")
//{
e.Appearance.BackColor = Color.Red;
//FontFamily tmp = new FontFamily("黑体");
e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
//e.Appearance.BackColor2 = Color.Red;
}
else
{
e.Appearance.BackColor = Color.Green;
}
}
FieldIndex++;
if (FieldIndex >= ((ReportData)DataSource).Blind[bindCount].AnalysisElement.Count) FieldIndex = 0;
//}
}
private void xrChart1_PrintOnPage(object sender, PrintOnPageEventArgs e)
{
if (e.PageIndex < ((ReportData)DataSource).Blind.Count && bindCount < e.PageCount)
{
bindCount++;
}
}
private void xrPivotGrid1_PrintFieldValue(object sender, DevExpress.XtraReports.UI.PivotGrid.CustomExportFieldValueEventArgs e)
{
if (e != null && e.Value != null && !e.Value.ToString().Contains("Total"))
{
if (((ReportData)DataSource).Blind.Count > bindCount && ((ReportData)DataSource).Blind[bindCount].AnalysisElement[FieldIndex].Comment == "超标")
//if (e != null && e.Value != null && e.Value.ToString() == "超标")
{
//if (e != null && e.Value != null && e.Value.ToString() == "超标")
//{
e.Appearance.BackColor = Color.Red;
//FontFamily tmp = new FontFamily("黑体");
e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
//e.Appearance.BackColor2 = Color.Red;
}
else
{
//if (e != null && e.Value != null && e.Value.ToString() == "超标")
//{
e.Appearance.BackColor = Color.Green;
//FontFamily tmp = new FontFamily("黑体");
//e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
//e.Appearance.BackColor2 = Color.Red;
}
}
}
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
if (adder != 0 && adder % 2 == 0) //每页显示8条
{
Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.BeforeBand;
}
else
{
Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.None;
}
adder++;
}
}
}