This is a migrated thread and some comments may be shown as answers.
Export Command Problems
7 Answers 67 Views
This is a migrated thread and some comments may be shown as answers.
Kevin Donahue
Top achievements
Rank 1
Kevin Donahue asked on 21 Nov 2012, 05:59 AM
I have a RadGrid with the export to PDF and export to Excel buttons enabled.

Recently I added a button inside my Column Headers and now when I press the export to pdf button I get the following error:

System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'.
at Telerik.Web.Apoc.Fo.Flow.BlockContainer.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)


When I click on the export to excel button, it puts all the page HTML into the excel spreadsheet instead of just the grid.

Any ideas?  Is there any way to ignore html controls in the grid?

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 21 Nov 2012, 10:43 AM
Hi,

Such error occurs when you have DIV element with specified dimensions or absolute positioning. In order to avoid this exception, remove the relevant width/height/position attributes.Also check the following help documentation which explains more about exporting to pdf. Please provide your code if it doesn't help.
PDF Export

Thanks,
Princy.  
0
Daniel
Telerik team
answered on 21 Nov 2012, 05:55 PM
Hello Kevin,

Also sometimes this could happen even if you haven't set these explicitly. Some controls are rendered as a DIV element or have DIV wrappers and if you set a specific width/height on them this could trigger the exception when exporting to PDF.
Please excuse us for any inconvenience caused.

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kevin Donahue
Top achievements
Rank 1
answered on 21 Nov 2012, 11:12 PM
Hey guys,  thanks for that.  I removed all the divs and it is now generating export documents, however in the excel export, the button that I have in my header is ending up within the excel document.  Is there any way to exclude this button from exporting?

I have linked some screenshots.  The first one shows my button in the header, and the second one shows my excel output from the export.  The button turns into a big grey square in the excel spreadsheet.

RadGrid With Button in Header

Export To Excel
0
Princy
Top achievements
Rank 1
answered on 22 Nov 2012, 04:30 AM
Hi,

Try setting ExportOnlyData as true.
aspX:
<ExportSettings OpenInNewWindow="true" ExportOnlyData="true" ></ExportSettings>

Thanks,
Princy. 
0
Kevin Donahue
Top achievements
Rank 1
answered on 22 Nov 2012, 04:54 AM
Hi Princy,

That attribute is already on.  Turning it off makes the excel spreadsheet look even worse.

This is what I'm adding to the selected column header:

<input type="Image"  src="images/Exo.png" style="height:24px;"/><br/>

If I use an image instead, the image ends up in both the excel export file and pdf export file.  With the input control, it gets ignored by the pdf export, but I get the grey box for the excel one.
0
Kevin Donahue
Top achievements
Rank 1
answered on 22 Nov 2012, 05:06 AM
Can the text of a cell be changed before exporting?

I tried using this event:

        protected void rgSummary_ExcelExportCellFormatting(object sender, ExcelExportCellFormattingEventArgs e)
        {
            if (e.FormattedColumn.UniqueName.Contains("<input type=\"Image\" src=\"images/Exo.png\"/>"))
            {
                e.FormattedColumn.HeaderText.Replace("<input type=\"Image\" src=\"images/Exo.png\"/>", "");
            }
        }

But I'm not sure how to change the text.
0
Daniel
Telerik team
answered on 26 Nov 2012, 12:56 PM
Hello Kevin,

If you are going the change the column's header text I would recommend that you use the ItemCommand event (when using built-in export buttons) or button_click when your export button is external.
CellFormatting event is not suitable for changing column settings.

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Kevin Donahue
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Daniel
Telerik team
Kevin Donahue
Top achievements
Rank 1
Share this question
or