在標記(如果您正在使用AJAX控件),您可以如下定義(頁腳)彙總格式:
<telerik:GridBoundColumn DataField="columnName" HeaderText="Money" UniqueName="uniqueColumnName"
DataFormatString="{0:C}" Aggregate="Sum" FooterAggregateFormatString="{0:C}" />
這將在顯示和輸出電網來實現。然而,您可能不想在屏幕上顯示它;在這些情況下,您可以更新導出事件處理程序中的屬性。您還應該注意,從上面的標記中可以得到一個DataFormatString
屬性,它可以格式化單元格中顯示的數據。
protected void RadGrid_OnExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
if ((e.FormattedColumn.DataType == typeof(long))) {
e.Cell.Style("mso-number-format") = "Currency";
if (((e.FormattedColumn) is GridBoundColumn)) {
GridBoundColumn col = e.FormattedColumn;
col.FooterAggregateFormatString = "{0:C}";
}
}
}
你本來做了GridExporting
事件處理程序:
protected void RadGrid_GridExporting(object sender, GridExportingArgs e)
{
GridColumn gridCol = grdCustomers.MasterTableView.GetColumnSafe("uniqueColumnName");
if (((gridCol) is GridBoundColumn)) {
GridBoundColumn boundCol = (GridBoundColumn)gridCol;
boundCol.FooterAggregateFormatString = "{0:C}";
}
}
我敢肯定,鑄造等上面做可以更有效地執行/正常,但上面的代碼應該是一個合理的地方開始。