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

Format column in export Excel from radgrid.

4 Answers 397 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aks
Top achievements
Rank 1
aks asked on 25 Jan 2012, 10:11 PM
I am exporting a radgrid to Excel.  The columns are exporting, but the data is formatted incorrectly.  I am using OnExcelMLExportStylesCreated.  I would like to format a number column to include commas in the number (ex. 1,000) but with no decimals.  What am I doing wrong?  I've tried every number format type.

Also, how do I format a date field to be MM/dd?

Thanks in advance.

protected void grdOpenItemsByJurisdiction_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
        {
            StyleElement myStyle = new StyleElement("myCustomStyle");
           
            myStyle.NumberFormat.FormatType =  NumberFormatType.GeneralNumber;
            myStyle.NumberFormat.Attributes["ss:Format"] = "0";
            myStyle.FontStyle.Bold = true;
            e.Styles.Add(myStyle);
        }

protected void grdWorkItemsJurisdiction_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
        {
 
            e.Row.Cells.GetCellByName("TotalItems").StyleValue = "myCustomStyle";
   
        }

4 Answers, 1 is accepted

Sort by
0
aks
Top achievements
Rank 1
answered on 26 Jan 2012, 07:07 PM
Bump..
0
Shinu
Top achievements
Rank 1
answered on 27 Jan 2012, 05:14 AM
Hello,

You can style columns in ExcelExportCellFormatting  event. Check the following help documentation which explains more about this.
Word/Excel export (HTML-based).

-Shinu.
0
khalid
Top achievements
Rank 1
answered on 27 Jul 2015, 12:15 PM

can you please give me full code for HTML based formating to Export. I have seen few lines of code but i need full export code. As some of my columns are populating online side means when open into browser then i can fill some columns.

thanks

0
Eyup
Telerik team
answered on 30 Jul 2015, 11:10 AM
Hello Khalid,

You can find an actual live sample here:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/excel-export/defaultcs.aspx

Do you mean that you are creating the columns programmatically?
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/defining-structure/creating-a-radgrid-programmatically

Hope this helps. If you have different requirements or further instructions, please elaborate on your specific scenario and send us sample screenshots or video demonstrating the desired behavior.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
aks
Top achievements
Rank 1
Answers by
aks
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
khalid
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or