DevExpress.XtraReports:XRPivotGrid 笔记

1.

DevExpress.XtraReports:XrPivotGrid 显示时间为"0"的 格式问题:

 把xrPivotGridField1的SummaryType改为"Max"或者"Min";

 

另外在Cell格式化时间默认日期时间一起显示的,

如果只想显示为Time(不显示日期部门)只需设置xrPivotGridField1属性中的CellFormat为DateTime "t"

如果只想显示为Date(不显示时间部分)只需设置xrPivotGridField1属性中的CellFormat为DateTime "d" 

 

以下设置只影响GrandTotal(总计),不影响小计

       this.pivotGridField12.GrandTotalCellFormat.FormatString = "t";

       this.pivotGridField12.GrandTotalCellFormat.FormatType = DevExpress.Utils.FormatType.DateTime;

 

 2.

          //this.xrPivotGrid1.OptionsView.ShowColumnHeaders = false;//显示列头
            this.xrPivotGrid1.OptionsView.ShowDataHeaders = false;//显示数据头
            this.xrPivotGrid1.OptionsView.ShowColumnTotals = false;//显示横向分组小计
            //this.xrPivotGrid1.OptionsView.ShowColumnGrandTotals = false;//显示横向总计
           this.xrPivotGrid1.OptionsView.ShowRowGrandTotals = false;//显示纵向总计
          //  xrPivotGrid1.ShowColumnGrandTotalHeader = false;//横向总计总表头文本("Grand Total")

        
            this.xrPivotGridField5.Options.ShowGrandTotal = false;            //不做总计显示
            this.xrPivotGridField6.Options.ShowTotal = false;        //不做小计显示

3.添加自定义总计列(未测试)

 
 
复制代码
if (xrPivotGridField5.Area == PivotArea.ColumnArea)
                         {            
xrPivotGridField5.CustomTotals.Clear();           
xrPivotGridField5.CustomTotals.Add(DevExpress.Data.PivotGrid.PivotSummaryType.Average);
xrPivotGridField5.CustomTotals.Add(DevExpress.Data.PivotGrid.PivotSummaryType.Max);
xrPivotGridField5.TotalsVisibility = PivotTotalsVisibility.CustomTotals;
                         }
复制代码

 4.对齐方式(这里pivotGridControl使用Winform的控件)

 

   //其他cell对齐方式类似
            this.pivotGridControl2.Appearance.FieldValueTotal.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//小计标题居中对齐
            this.pivotGridControl2.Appearance.FieldValueGrandTotal.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//合计标题居中对齐

 

            this.pivotGridControl2.Appearance.FieldValue.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//字段列居中对齐

 

 

 5.

  //关于统计标题的修改
        private void pivotGridControl2_FieldValueDisplayText(object sender, DevExpress.XtraPivotGrid.PivotFieldDisplayTextEventArgs e)
        {           
            if (e.ValueType == DevExpress.XtraPivotGrid.PivotGridValueType.GrandTotal)//总计
            {
                if (e.IsColumn &&e.DisplayText.Trim()=="Grand Total")//第一层列总计标题
                {
                    e.DisplayText = "总计";
                }else
                if (e.IsColumn)//其他层列总计标题
                {
                    e.DisplayText = e.DisplayText + "总计"; 
                }
                else if (e.IsColumn == false && e.DisplayText.Trim() == "Grand Total")//第一层行总计标题
                {
                    e.DisplayText = "总计";
                }
                else//这种情况似乎不会发生
                {
                    e.DisplayText = "";
                }
            }
            else if (e.ValueType == DevExpress.XtraPivotGrid.PivotGridValueType.Total)//小计
            {
                if (e.IsColumn && e.Value != null)//第一层列小计标题
                {
                   // e.DisplayText = e.DisplayText.Replace("Total", "").Trim() + "小计";
                    e.DisplayText = e.Value + "小计";
                }
                else if(e.IsColumn )//其他层列小计标题
                {
                    e.DisplayText = e.DisplayText.Replace("Total", "").Trim() + "合计";
                }
            }
            else if (e.ValueType == DevExpress.XtraPivotGrid.PivotGridValueType.CustomTotal)//其他自定义合计类型
            {

            }
        }

 

你可能感兴趣的:(DevExpress)