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

Export to Excel and &nbsp

3 Answers 457 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maria
Top achievements
Rank 1
Maria asked on 10 Sep 2009, 07:36 AM
Hello,

I had an issue of empty cells in grid don't have borders,
I resolved it with adding &nbsp to all cells:

protected void grid_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
    {
        if (e.Column is GridBoundColumn)
        {
            (e.Column as GridBoundColumn).DataFormatString = "<nobr>&nbsp{0}</nobr>";
            //(e.Column as GridBoundColumn).DataFormatString = "<nobr>{0}</nobr>";
        }
    }

However this causes me another problem: the &nbsp is present when exporting to Excel.

What should I do?

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 14 Sep 2009, 02:39 PM
Hello Maria,

Although this question has been answered in the support ticket you have submitted I will use this forum thread to make the solution to this issue available for the rest of the community. Here are two forum threads that discuss such problems:

ASP.NET Controls - Grid Forum - Export To Excel Problem

ASP.NET Controls - Grid Forum - export money values to Excel


Hope this helps,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Maria
Top achievements
Rank 1
answered on 14 Sep 2009, 02:54 PM
Hello,

I'm not sure we understand each other, as I don't understand how these links help me to get read of the &nbsp string added to all cells.
The &nbsp is not some Excel formatting issue like the dates and numbers in the attached links, but its how the data generated when exporting to Excel.

Thanks
0
Martin
Telerik team
answered on 17 Sep 2009, 10:24 AM
Hello Maria,

I am pasting my answer here as well to make it available for the community.

There is another way to sidestep the empty cells' problem - to use the empty-cells: show CSS setting. This, however will possibly affect the exported file because the &nsbp; character causes Excel to interpret the value as string.

My idea was to avoid the &nbsp; tags as far as possible. However this may introduce another issue - Microsoft Excel will auto-format your values. This may lead to stripped leading zeroes and unwanted formatting. To prevent such behavior you should use the ExcelExportCellFormatting event to set the appropriate mso-number-format style (as depicted in the previous post).

For more information:
Empty cells in HTML tables
mso-number-format style

Regarding the other questions:

The website seems to be very slow
I believe this was a temporary problem - it should be running normally now.

I can't browse my forum messsage and getting server error
I checked the provided link, but it's not correct in my opinion - please examine the actual link below:
http://www.telerik.com/community/forums/aspnet-ajax/grid/export-to-excel-and-amp-nbsp.aspx

 I accidentally clicked on "format code block" icon on the toolbar in this editor, got some empty radwindow that can't be closed and all the page got stack.
This may also be related to a temporary problem since I can't reproduce it now.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Maria
Top achievements
Rank 1
Answers by
Martin
Telerik team
Maria
Top achievements
Rank 1
Share this question
or