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

Image not Displayed in Exported Excel

5 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Naresh
Top achievements
Rank 2
Naresh asked on 17 May 2011, 01:39 PM
Hi,

 i have binded the image in <ItemTemplate> like this:
<telerik:RadGrid ID="rgQuotes" Width="97%" AllowPaging="True" PageSize="15" runat="server"
            AllowSorting="True" OnNeedDataSource="rgQuotes_NeedDataSource" GridLines="None"
            Skin="Office2007" OnItemDataBound="rgQuotes_ItemDataBound" OnItemCreated="rgQuotes_ItemCreated"  onitemcommand="rgQuotes_ItemCommand"
            AutoGenerateColumns="False" AllowFilteringByColumn="True" AlternatingItemStyle-CssClass="alternativegridstyle">
            <AlternatingItemStyle CssClass="alternativegridstyle" />
            <GroupingSettings CaseSensitive ="false" />
            <MasterTableView Width="100%" DataKeyNames="QuoteId">
                <ItemTemplate>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td style="border: 0;" width="10%">
                                <img src="<%# "../Thumbnails.aspx?width=130&image=" + Eval("FullImagePath")%>"
                                style="cursor: pointer;border-style: none;" onclick= '<%# string.Format("return ImageDetails(\"{0}\",\"{1}\");",Eval("InventoryId"),Eval("ItemType")) %>' />
                            </td>
                            <td style="border: 0; width: 10%">
                                <table width="100%" border="0" cellspacing="0" class="quotelistimage">
                                    <tr>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnEdit" runat="server" ImageUrl="~/Images/edit.png" OnClientClick='<%# Eval("QuoteId","return EditQuote({0})") %>'
                                                ToolTip="Edit Quote" />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnCreateQuote" OnClientClick='<%# string.Format("return ReAssignQuote(\"{0}\", \"{1}\");",Eval("QuoteId"),Eval("StockID")) %>'
                                                runat="server" ImageUrl="~/Images/reAssign.png" ToolTip="Re-Assign Quote" />
                                        </td>
                                        <td style="border: 0;">
                                         
                                            <asp:ImageButton ID="ibtnClose" runat="server" OnClientClick='<%# string.Format("return CloseQuote(\"{0}\", \"{1}\", \"{2}\");",Eval("QuoteId"),Eval("QuoteNumber"),Eval("StockID")) %>'
                                                ImageUrl="~/Images/CloseQuote.png" ToolTip="Close Quote" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnCredit" runat="server" ImageUrl="~/Images/credit.png" OnClientClick='<%# string.Format("return AddCreditApplication(\"{0}\", \"{1}\", \"{2}\", \"{3}\",\"{4}\",\"{5}\",\"{6}\");",Eval("QuoteId"),Eval("StockID"),Eval("CreditID"),Eval("CreditType"),Eval("FinanceRequired"),Eval("ContactName"), Eval("ContactID")) %>' />
                                            <asp:Label runat="server" ID="lblCredit" Text='<%# Eval("CreditID") %>' Style="display: none;" Visible ="false" />
                                            <asp:Label runat="server" ID="lblFinance" Text='<%# Eval("FinanceRequired") %>' Style="display: none;" Visible="false" />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnImages" runat="server" ToolTip="Buyer Order" OnClientClick='<%# Eval("QuoteId","return OpenBuyerOrder({0})") %>'
                                                ImageUrl="~/Images/Quote_Buyer_Order.png" />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnDealerForm" runat="server" ImageUrl="~/Images/Quote_Dealer_Form.png"
                                                ToolTip="Dealer Forms" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnCustomer" runat="server" OnClientClick='<%# Eval("QuoteId","return OpenCustomerProposal({0})") %>'
                                                ImageUrl="~/Images/Quote_Customer_Proposal.png" ToolTip="Customer Proposal" />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnQuote" runat="server" ToolTip="Docs" OnClientClick='<%#Eval("QuoteId","return QuoteDocument({0})") %>'
                                                ImageUrl="~/Images/Quote_Doc.png" />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnEmail" OnClientClick='<%# string.Format("return QuoteEmail(\"{0}\",\"{1}\");",Eval("QuoteId"),Eval("QuoteNumber")) %>'
                                                runat="server" ImageUrl="~/Images/email.png" ToolTip="E-Mail" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnAnalyze" OnClientClick='<%# Eval("QuoteId","return OpenDealSheet({0})") %>'
                                                runat="server" ImageUrl="~/Images/deal.png" ToolTip="Deal Analysis" />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnQuoteInventory" runat="server" OnClientClick='<%# Eval("QuoteId","return ViewMultipleInventoryQuote({0})") %>'
                                                ImageUrl="~/Images/more-qoute.png" ToolTip='<%#  " "+Eval("cnt")+" Inventory Found" %>' />
                                        </td>
                                        <td style="border: 0;">
                                            <asp:ImageButton ID="ibtnApprove" Visible="false" Style="border-bottom: solid 1px Transparent"
                                                runat="server" OnClientClick='<%# Eval("QuoteID","return QuoteApprove({0})") %>'
                                                ImageUrl="~/Images/Approve.png" ToolTip="Approve Quote" />
                                            <asp:ImageButton ID="ibtnFIApprove" Visible="false" Style="border-bottom: solid 1px Transparent;"
                                                runat="server" OnClientClick='<%# string.Format("return QuoteApproveFI(\"{0}\", \"{1}\");",Eval("QuoteId"),Eval("CreditID")) %>'
                                                ImageUrl="~/Images/Approve.png" ToolTip="FI Approve Quote" />
                                            <asp:Label ID="lblStatus" runat="server" Visible="false" Text='<%# Eval("Status") %>'></asp:Label>
                                            <asp:Label ID="lblQuoteApprove" runat="server" Visible="false" Text='<%# Eval("QuoteApprove") %>'></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td style="border: 0; width: 70%;">
                                <table style="width: 100%; border: 1px solid #ececec;" cellpadding="0" cellspacing="0"
                                    align="left">
                                    <tr>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Quote Number
                                            </div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <%# Eval("QuoteNumber")%> </div>
                                        </td>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Quote Date</div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                              <%--  <%# Eval("CreatedDate", "{0:MM/dd/yyyy}")%>--%>
                                              <%# Eval("DateOnly") %>
                                                 </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Sales Person
                                            </div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <asp:Label ID="lblUserName" onclick='<%# Eval("CreatedBy","return SalesMan({0})") %>'
                                                    runat="server" Style="text-decoration: underline" Text='<%# Eval("UserName")%>'></asp:Label> </div>
                                        </td>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Location Name
                                            </div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <%# Eval("LocationName")%> </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Contact Name
                                            </div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <%# Eval("ContactName")%> </div>
                                        </td>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Contact City
                                            </div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <%# Eval("ContactCity")%> </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Stock Number
                                            </div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <%# Eval("StockID")%>
                                                  
                                            </div>
                                        </td>
                                        <td width="20%">
                                            <div class="quotelistheadlabel">
                                                Make/Model</div>
                                        </td>
                                        <td width="30%">
                                            <div class="quotelistheadcontent">
                                                <%# Eval("Make")%>/<%# Eval("Model")%>
                                                 </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>

This the server side code for Export Event:

protected void btnExcel_Click(object sender, EventArgs e)               //Button Export to Excel Event
    {
        //Export the data
        try
        {
 
            isExport = true;
            rgQuotes.MasterTableView.ShowHeader = false;
            foreach (GridDataItem data in rgQuotes.MasterTableView.GetItems(GridItemType.Item))
            {
                Label lblStatus = (Label)data.FindControl("lblCredit");
                Label lblQuoteApprove = (Label)data.FindControl("lblFinance");
                lblStatus.Visible = false;
                lblQuoteApprove.Visible = false;
            }
            rgQuotes.ExportSettings.ExportOnlyData = true;
            rgQuotes.ExportSettings.IgnorePaging = true;
            rgQuotes.ExportSettings.FileName = "Quotes";
            rgQuotes.MasterTableView.ExportToExcel();
             
        }
        catch (Exception ex)
        {
            CommonFunctions.AddErrorLog("Sales=>Quotes", "btnExcel_Click", ex);
        }
        //Export the data in excel file format
    }

Images will be displayed in Excel sheet when application runs in IE Browser
While we switched over to FF then Images wont be exported to Excel sheet.
Its urgent. Please give me a solution.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 May 2011, 02:08 PM
Hello Nagarajan,

The following forum thread discusses the same scenario. Check the thread for more details.
Export Image RadGrid to Excel.

Thanks,
Princy.
0
Naresh
Top achievements
Rank 2
answered on 17 May 2011, 02:23 PM
Hi Princy,

That link didn't open for me.. Please give me the solution ASAP. Its Urgent
0
Princy
Top achievements
Rank 2
answered on 18 May 2011, 04:53 AM
Hello Nagarajan,

Sorry for the incorrect link. Check the following forum thread.
Export Image RadGrid to Excel.

Thanks,
Princy.
0
Naresh
Top achievements
Rank 2
answered on 18 May 2011, 06:09 AM
Hi,

I tried those concept. it exported the only the columns of grid.
i have used the <itemTemplate> of MasterTableView.
 it Wont'be exported to excel while using third party components.
0
Daniel
Telerik team
answered on 20 May 2011, 02:16 PM
Hello Nagarajan,

Of course, the NPOI demo is a proof of concept. You can modify it to export all data as per your requirements:
Export to Excel with third-party library (NPOI)

Regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Naresh
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Naresh
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or