This is a migrated thread and some comments may be shown as answers.

Excel Export  

3 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 2
Veteran
MBEN asked on 07 Feb 2019, 11:33 PM

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 &nbsp; 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 &#10; 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 />", " ");
    }

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Feb 2019, 02:30 PM
Hello,

You can try replacing the <br/> snippets with Environment.NewLine and see whether this changes anything. 

If the issue remains, I suggest that for quick resolution of this case you can modify the sample provided in the following post to demonstrate the issue and open a formal support ticket to send it back to us:
https://www.telerik.com/forums/how-do-i-add-multiple-footer-rows-to-a-grid#xdh3rJWHL0CuHyPucOo6Cw

This will enable us to provide a solution specific to your own scenario.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
MBEN
Top achievements
Rank 2
Veteran
answered on 13 Feb 2019, 05:13 PM
I added a support ticket.
0
Eyup
Telerik team
answered on 14 Feb 2019, 09:55 AM
Hello,

Thank you for doing that. I've provided a reply with a working solution in the mentioned support ticket. I suggest that we continue our technical conversation on the mentioned thread.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
MBEN
Top achievements
Rank 2
Veteran
Answers by
Eyup
Telerik team
MBEN
Top achievements
Rank 2
Veteran
Share this question
or