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

[Solved] Export Excel - Extra Column & Caption Not aligning

7 Answers 278 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradip
Top achievements
Rank 1
pradip asked on 02 Apr 2009, 02:07 AM

Hi 

I am working on Export Excel; But I am looking for few answers...

1. How to align Caption to Right side.... I need Caption only for Excel so I am creating it while calling Excel only.... I tried using CssClass but it is not working..... I am not using "CommandItemTemplate"......

 

 

2. I am getting extra column on right side on excel for all views, except default mastertable view... Could you please suggest wht is that I am doing wrong? And how to remove to extra column?

3. Also Table is not getting border completly.... Top side of Header and bottom side of table is not showing border... could you suggest the way to achieve it..

Please see below look of Excel ........Caption is set in 3 rows, but it is showing me in center, I want it on right side....
Also please extra column on right hand side...and border issues....

Thanks,
Pradip

Client Name
Detail
Detail 2
Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Column 10 Column 11 Column 12 Column 13  
Client 1     '08/'09 81,691,829 81,691,829 81,691,829 $6,044,001 $6,044,001 $6,044,001 $0.074 $0.074 $0.074  
  Sub 1   '08/'09 7,038,183 7,038,183 7,038,183 $692,072 $692,072 $692,072 $0.098 $0.098 $0.098  
Sub 4   '08/'09 16,773,133 16,773,133 16,773,133 $1,660,219 $1,660,219 $1,660,219 $0.099 $0.099 $0.099  
Sub 5   '08/'09 6,692,000 6,692,000 6,692,000 $886,796 $886,796 $886,796 $0.133 $0.133 $0.133  
Client 2     '08/'09 152,417,843 152,417,843 152,417,843 $8,635,388 $8,635,388 $8,635,388 $0.057 $0.057 $0.057  
Client3     '08/'09 35,796,307 35,796,307 35,796,307 $276,533 $276,533 $276,533 $0.008 $0.008 $0.008  
Client 4     '08/'09 3,387,345 3,387,345 3,387,345 $54,711 $54,711 $54,711 $0.016 $0.016 $0.016  

7 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 06 Apr 2009, 02:01 PM
Hello pradip,

For more flexible customization of the RadGrid content when exported to Excel, I suggest you consider using the native export (ExcelML) supported by the control and its event-driven customization of grid cells/text. Here are a couple of online resources which elaborate on this subject:

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grdexport.html (the section concerning export to ExcelML)

To hide empty columns from the exported document, consider hiding them right before the export action takes place as explained in this help topic (paragraph "Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data").

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Eric
Top achievements
Rank 1
answered on 16 Apr 2009, 03:15 PM
I've noticed that the CommandItemTemplate and its contents will be exported to Excel when using GridExcelExportFormat.Html;

Is there a way to get the CommandItemTemplate to export when using GridExcelExportFormat.ExcelML as well?

The goal is to add a header section to the exported excel file.  Is there a way to do this with the ExcelML formattin by either using the CommandItemTemplate or the .Caption property?

Thank you,


0
Sebastian
Telerik team
answered on 16 Apr 2009, 03:17 PM
Hello Eric,

Is using the Caption property of the master table for this purpose applicable solution for your case? Try it our and let us know how it goes.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Eric
Top achievements
Rank 1
answered on 16 Apr 2009, 03:23 PM
When exporting with ExcelML, the Caption does not end up in the Excel file.

If this is possible to do then this will be an acceptable solution as I can put HTML markup in the Caption property.
0
Pavel
Telerik team
answered on 21 Apr 2009, 07:57 AM
Hello Eric,

Unfortunately the Caption cannot be exported when exporting to ExcelML. As a workaround I can suggest you to add an additional row using the ExcelMLExportRowCreated event handler and add the data to it as needed. I hope this helps.

Regards,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Eric
Top achievements
Rank 1
answered on 25 Apr 2009, 10:33 PM
Thank you,

Is there an example anywhere than you can provide the link to?
0
Pavel
Telerik team
answered on 28 Apr 2009, 06:32 AM
Hi Eric,

You can use the following code-snippet as a reference:

protected void RadGrid1_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e) 
    if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.HeaderRow) 
    { 
        Telerik.Web.UI.GridExcelBuilder.RowElement row = new Telerik.Web.UI.GridExcelBuilder.RowElement(); 
        Telerik.Web.UI.GridExcelBuilder.CellElement cell = new Telerik.Web.UI.GridExcelBuilder.CellElement(); 
        cell.Data.DataItem = "Test"
        row.Cells.Add(cell); 
        e.Worksheet.Table.Rows.Insert(0, row); 
    }     

Kind regards,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
pradip
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Eric
Top achievements
Rank 1
Pavel
Telerik team
Share this question
or