
Wendy Lucas
Top achievements
Rank 1
Wendy Lucas
asked on 12 Mar 2009, 03:14 PM
Hi, I have a RadGrid containing images that I want to export to Excel and PDF. Having done some experimenting and read the forums, I have come to the below conclusions. I would be grateful if anyone could let me know whether or not my conclusions are correct?
1. ExportToExcel will only export images which have a full URL e.g. http://MyServer.MyImage.jpg. It will not export images with a relative URL e.g. ~\MyImage.jpg. In the latter case, red crosses appear in Excel.
2. The reverse is true for ExportToPdf. An image with a relative URL exports fine. With a full URL, I get the following error message:
'Adobe Reader could not open 'MyExport[1].pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).'
I am using the Q2 2008 Rad controls.
Many thanks
Wendy
1. ExportToExcel will only export images which have a full URL e.g. http://MyServer.MyImage.jpg. It will not export images with a relative URL e.g. ~\MyImage.jpg. In the latter case, red crosses appear in Excel.
2. The reverse is true for ExportToPdf. An image with a relative URL exports fine. With a full URL, I get the following error message:
'Adobe Reader could not open 'MyExport[1].pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).'
I am using the Q2 2008 Rad controls.
Many thanks
Wendy
7 Answers, 1 is accepted
0
Hello Wendy,
Straight to your questions:
1) You can't export images to Excel. Only references to them are exported.
2) Export to PDF should export both relative and full URLs as shown in the following code:
Let me know if you have more questions.
Regards,
Daniel
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.
Straight to your questions:
1) You can't export images to Excel. Only references to them are exported.
2) Export to PDF should export both relative and full URLs as shown in the following code:
<ItemTemplate> |
<asp:Image ID="Image1" runat="server" ImageUrl="http://www.google.bg/images/nav_logo3.png" |
AlternateText="Image" /> |
<asp:Image ID="Image2" runat="server" ImageUrl="~/myImage.png" AlternateText="Image" /> |
</ItemTemplate> |
Let me know if you have more questions.
Regards,
Daniel
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

Wendy Lucas
Top achievements
Rank 1
answered on 16 Mar 2009, 03:43 PM
Thanks for your reply Daniel. I can't get full URLs to to export to PDF without getting the error message I mentioned in my post... Below is my grid & the code behind.
<telerik:RadGrid ID="rgReportResults" runat="server" |
AllowPaging="True" |
GridLines="Vertical" |
AllowSorting="True" |
Skin="Gray" |
AutoGenerateColumns="False" |
> |
<MasterTableView AllowMultiColumnSorting="True" CommandItemDisplay="Top"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<CommandItemTemplate> |
<p style=" color: White; font-weight: bold">Export current page to: |
<asp:Button Runat="server" ID="cmdExportToPdf" Text="PDF" CssClass="button" OnClick="cmdExportToPDF_Click"></asp:Button> |
</p> |
</CommandItemTemplate> |
<ItemTemplate> |
<asp:Image ID="Image1" runat="server" ImageUrl="http://www.google.bg/images/nav_logo3.png" AlternateText="Image" /> |
</ItemTemplate> |
<CommandItemStyle HorizontalAlign="Right" /> |
<PagerStyle AlwaysVisible="True" Mode="NextPrevAndNumeric" /> |
<ItemStyle VerticalAlign="Top" /> |
<AlternatingItemStyle VerticalAlign="Top" /> |
<Columns> |
<telerik:GridBoundColumn UniqueName="column"> |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
<FilterMenu EnableTheming="True" Skin="Vista"> |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</FilterMenu> |
<PagerStyle Mode="NextPrevAndNumeric" /> |
<ClientSettings ReorderColumnsOnClient="True" EnableRowHoverStyle="True"> |
<Resizing AllowColumnResize="True" /> |
</ClientSettings> |
<ExportSettings FileName="AutoReport" IgnorePaging="True" OpenInNewWindow="True" ExportOnlyData="false"> |
</ExportSettings> |
</telerik:RadGrid> |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!Page.IsPostBack) |
{ |
string[] images = new string[3]; |
rgReportResults.DataSource = images; |
rgReportResults.DataBind(); |
} |
} |
protected void cmdExportToPDF_Click(object sender, EventArgs e) |
{ |
rgReportResults.MasterTableView.ExportToPdf(); |
//rgReportResults.MasterTableView.ExportToExcel(); |
} |
0
Hello Wendy,
Thank you for the example.
Please let me know which version is used in your project. I successfully exported the file using the code you provided. You can find both the PDF output file and the website attached to this post.
Best regards,
Daniel
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.
Thank you for the example.
Please let me know which version is used in your project. I successfully exported the file using the code you provided. You can find both the PDF output file and the website attached to this post.
Best regards,
Daniel
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

Wendy Lucas
Top achievements
Rank 1
answered on 23 Mar 2009, 02:55 PM
Hi Daniel
I'm using version 2008.2.723.20 of the Telerik.Web.UI, and Visual Studio 2005.
The page you sent through still gave me the error message (though I wasn't able to use your web.config as it was raising errors on my machine).
Thanks
Wendy
I'm using version 2008.2.723.20 of the Telerik.Web.UI, and Visual Studio 2005.
The page you sent through still gave me the error message (though I wasn't able to use your web.config as it was raising errors on my machine).
Thanks
Wendy
0
Hello Wendy,
We strongly recommend that you upgrade to the latest version of RadControls where many improvements/fixes are introduced.
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
We strongly recommend that you upgrade to the latest version of RadControls where many improvements/fixes are introduced.
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0

Wendy Lucas
Top achievements
Rank 1
answered on 25 Mar 2009, 03:06 PM
OK, I've now upgraded. When I click to export to pdf, I'm now getting an error as follows (which I haven't had a chance to investigate yet).
System.SystemException: System.SystemException: Error while creating area : Encountered web exception while fetching image from http://www.google.bg/images/nav_logo3.png: The underlying connection was closed: An unexpected error occurred on a receive.
at Telerik.Web.Apoc.ApocDriver.FireApocError(String message)
at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.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)
System.SystemException: System.SystemException: Error while creating area : Encountered web exception while fetching image from http://www.google.bg/images/nav_logo3.png: The underlying connection was closed: An unexpected error occurred on a receive.
at Telerik.Web.Apoc.ApocDriver.FireApocError(String message)
at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.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)
0
Hello Wendy,
I tested my sample project on several computers and I confirm that the image was exported without any errors. I suppose you may be behind a firewall which blocks the connection.
Let me know what your findings are.
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
I tested my sample project on several computers and I confirm that the image was exported without any errors. I suppose you may be behind a firewall which blocks the connection.
Let me know what your findings are.
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.