1.
DevExpress.XtraReports:XrPivotGrid 顯示時間為"0"的 格式問題:
把xrPivotGridField1的SummaryType改為"Max"或者"Min";
另外在Cell格式化時間默認日期時間一起顯示的,
如果只想顯示為Time(不顯示日期部門)只需設置xrPivotGridField1屬性中的CellFormat為DateTime "t"
如果只想顯示為Date(不顯示時間部分)只需設置xrPivotGridField1屬性中的CellFormat為DateTime "d"
以下設置只影響GrandTotal(總計),不影響小計
this.pivotGridField12.GrandTotalCellFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
//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的控件)
this.pivotGridControl2.Appearance.FieldValueTotal.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//小計標題居中對齊
this.pivotGridControl2.Appearance.FieldValueGrandTotal.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)//其他自定義合計類型
{
}
}