for normal cell i have written the below code to set number format
If e.FrameworkFormatStr.ToString.Contains("%") Then e.ExcelFormatStr = "0.00%;[Red](0.00%)" Else e.ExcelFormatStr = "#,###;[Red](#,###)" End If
the above code works perfectly for negative and positive numbers.
negative numbers is coming in red color enclosed within brackets
----
likewise i need to set format for summary columns or summary cells.
Hello Wiki,
I am just following up and see if you have any questions.
Thank you for contacting Infragistics!
It is possible to change the format of the summary cells by handling the WebExcelExporter's CellExported event as follows:
WebExcelExporter computes for the summary cell using Excel formula before it renders. In addition, since the summary cell may include a label together with the value, the summary cell is rendered as string. With the summary cell as string and not it's corresponding column's datatype or format, using FormatString my not be feasible. Excel formatting may be used instead.
protected void WebExcelExporter1_CellExported(object sender, Infragistics.Web.UI.GridControls.ExcelCellExportedEventArgs e)
{
if (e.IsSummaryCell && e.Summary != null)
if (e.Summary.CustomSummaryName == "CategoryCount")
e.WorksheetCell.CellFormat.Font.Italic = Infragistics.Documents.Excel.ExcelDefaultableBoolean.True;
e.WorksheetCell.CellFormat.Font.Bold = Infragistics.Documents.Excel.ExcelDefaultableBoolean.False;
e.WorksheetCell.CellFormat.Font.ColorInfo = Color.Purple;
}
else
if (e.Summary.CustomSummaryName == "PriceAverage")
string formula = "=\"PriceAverage = $\"&Round(AVERAGE(E2:E12),2)";
e.WorksheetCell.ApplyFormula(formula);
e.WorksheetCell.CellFormat.Font.ColorInfo = Color.Red;
if (e.Summary.CustomSummaryName == "PercentageMax")
string formula = "=\"PriceAverage = \"&Round(MAX(F2:F12),2)";
string cellValue = e.WorksheetCell.Value.ToString();
string newCellValue = cellValue + "%";
e.WorksheetCell.Value = newCellValue;
e.WorksheetCell.CellFormat.Font.ColorInfo = Color.Green;
e.WorksheetCell.CellFormat.Font.ColorInfo = Color.Blue;
For more information, you may refer to the attached sample. If you have any questions, please let me know as well.