I have a row of totals in my grid. I add a custom footer to my grid where I add a grand total for 3 total columns to the last cell. I add a <br /> and to all the other cells as shown below.
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
{
double a= 0;
double b= 0;
double c= 0;
double sumA = 0;
double sumB = 0;
double sumC = 0;
double total = 0;
foreach (GridDataItem item in e.Item.OwnerTableView.Items)
{
a= Double.Parse(item["A"].Text, NumberStyles.Currency);
sumA += a;
b= Double.Parse(item["B"].Text, NumberStyles.Currency);
sumB += b;
c= Double.Parse(item["C"].Text, NumberStyles.Currency);
sumC += c;
}
total = sumA + sumB + sumC;
footerItem["A"].Text = sumA .ToString("c2") + "<
br
/> ";
footerItem["B"].Text = sumB .ToString("c2") + "<
br
/> ";
footerItem["C"].Text = sumC.ToString("c2") + "<
br
/>" + total.ToString("c2");
}
on my excel export the blank cell does not show. It seems excel is ignoring the line break and empty cell and just bottom aligning the total for me. See attached.
I even tried the approach in some other threads to replace the <br /> with but that just takes the new line away completely.
protected void grid_GridExporting(object sender, GridExportingArgs e)
{
RadGrid grid = (RadGrid)sender;
e.ExportOutput = e.ExportOutput.Replace("<
br
/>", "
");
}