DevExpress.XtraReports:XRPivotGrid 筆記

來源:互聯網
上載者:User
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)//其他自訂合計類型
            {

            }
        }

 

 

 

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.