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)//其他自定义合计类型
            {

            }
        }

 

 

 

 

 

 

 

posted on 2011-04-28 15:22 NET未来之路 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/archive/2011/04/28/2031819.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值