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

Excel export, cell padding and AutoSum

2 Answers 389 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sphengle
Top achievements
Rank 1
Sphengle asked on 02 Feb 2010, 04:26 PM
In a grid I have some money data.  I've right align the column values but since they don't line up well with the column header and the next column I'm adding two nbsp characters to the right of the value - in order to provide a little padding.  These values when exported into Excel also have these padding characters.  Unfortunately these space charaters prevent Excel autosum from working correctly.  Even reformatting the Excel column doesn't work.

The question are ...

- Can I right align the values but have a little space to the right of the value without using space characters
- Is it possible to intercept the data before exporting to Excel and remove the space characters?
- In Excel how can one remove the padding characters easily?

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 05 Feb 2010, 03:23 PM
Hello Sphengle,

Straight onto your questions:

- Can I right align the values but have a little space to the right of the value without using space characters:
Yes, it is possible to apply padding as shown below:

protected void RadGrid1_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e)
{
    if (e.FormattedColumn.UniqueName == "ID")
        e.Cell.Style["padding-left"] = "30px";
}

- Is it possible to intercept the data before exporting to Excel and remove the space characters?
Of course you can, but you will hardly need this - you could use GridExporting or ExcelExportCellFormatting for that purpose.

- In Excel how can one remove the padding characters easily?
You can just delete any empty characters, if any. If you want to remove the real padding - right click on the cells and select FormatCells -> Alignment -> Indent

Kind regards,
Daniel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Sphengle
Top achievements
Rank 1
answered on 05 Feb 2010, 04:09 PM
Hi Daniel

Many thanks, that looks exactly like what I need.

Tags
Grid
Asked by
Sphengle
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Sphengle
Top achievements
Rank 1
Share this question
or