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

How to remove extra string when Exporting to Excel

1 Answer 47 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Raymond
Top achievements
Rank 1
Raymond asked on 07 Aug 2013, 10:17 PM
I have a very basic code that Export data from a GridView using Visual Basic. The problem I am encountering is the Excel file contains many extra space strings
For example instead '123', it is '123          '

Is there anyway to get rid of these extra strings?

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Aug 2013, 12:39 PM
Hi Raymond,

Thank you for writing.

A suitable event for customizing the value of the exported cells is the ExcelCellFormatting event. Here is an example:
void exporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
    if (e.ExcelCellElement.Data.DataItem is string)
    {
        e.ExcelCellElement.Data.DataItem = e.ExcelCellElement.Data.DataItem.ToString().TrimEnd(' ');
    }
}

I hope this helps.
 
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Raymond
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or