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

Export GridTemplateColumn via Biff

3 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vasssek
Top achievements
Rank 1
Vasssek asked on 29 Aug 2013, 09:10 AM
Hello,

I have issue with exporting radgrid to excel through Biff. Radgrid has some GridTemplateColumns which aren't correctly exported. When I use Excel-Format="ExcelML" result excel file shows data properly.

You can find further information in the attachment

Please help me to solve it...

Best regards

 Vasssek

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Aug 2013, 10:00 AM
Hi,

Below is a sample code snippet of Export to excel using Biff,which works fine at my end.Can you try it and see if this helps,else please provide your full code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" >
    <ExportSettings Excel-Format="Biff" IgnorePaging="true" ExportOnlyData="true" OpenInNewWindow="true">
    </ExportSettings>
    <MasterTableView DataKeyNames="OrderID" CommandItemDisplay="Top" CommandItemSettings-ShowExportToExcelButton="true">
        <Columns>
            <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />
            <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />
            <telerik:GridTemplateColumn DataField="ShipVia" HeaderText="ShipVia" UniqueName="ShipVia">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text=' <%# Eval("ShipVia")%>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Thanks,
Princy
0
Vasssek
Top achievements
Rank 1
answered on 30 Aug 2013, 06:34 AM
Hi Princy,

My case is quite different.

Here is the part of ASPX declaration:
<telerik:GridTemplateColumn DataField="31" HeaderText="31" HeaderStyle-Font-Bold="true"  HeaderStyle-Width="22px" HeaderStyle-HorizontalAlign="Center" ReadOnly="True" SortExpression="31" AllowFiltering="false" UniqueName="31">
                       <ItemTemplate>
                           <div style="width: 22px;">
                               <telerik:RadButton ID="RadButton31" runat="server" Width="16px" Height="16px" Image-EnableImageButton="true" ReadOnly='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? true : false%>'
                                   OnClick="ImageButton_Liefertreue_OnClick" ToolTip='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? "Žiadne objednávky" : String.Format("{0:0.##} %",DataBinder.Eval(Container.DataItem, "31"))%>'
                                   Image-ImageUrl='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? "~/Images/shading.png" : Convert.ToInt32(DataBinder.Eval(Container.DataItem, "31")) == App_Utils.intLiefetreue_success ? "~/Images/emoticon_happy.png": "xx" %>'
                                   Visible='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? true : Convert.ToInt32(DataBinder.Eval(Container.DataItem, "31")) != App_Utils.intLiefetreue_success ? false : true %>'>
                               </telerik:RadButton>
                               <asp:LinkButton ID="lblMyLink31" runat="server" Visible='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? false : true %>'
                                   Text='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? "" : Convert.ToInt32(DataBinder.Eval(Container.DataItem, "31")) != App_Utils.intLiefetreue_success ? DataBinder.Eval(Container.DataItem, "31"): "" %>'
                                   ToolTip='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? "Žiadne objednávky" : String.Format("{0:0.##} %",DataBinder.Eval(Container.DataItem, "31"))%>'
                                   ForeColor="Red" Font-Bold='<%#DataBinder.Eval(Container.DataItem, "31") is DBNull ? false : Convert.ToInt32(DataBinder.Eval(Container.DataItem, "31")) == 0 ? false: true %>' Font-Underline="false" OnClick="ImageButton_Liefertreue_OnClick"></asp:LinkButton>
                           </div>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>

And the result column value in the exported excel file:
<div style="width: 22px;">False                            </div>

For your imagination, radgrid represents month with 31 days. Based on some logic, there is either green smile face or red value when it is not accomplished on 100%...

Regards

Vasssek
0
Accepted
Kostadin
Telerik team
answered on 03 Sep 2013, 07:25 AM
Hello Vasssek,

The reason for the differences between the exported formats is that the exporting data are different in both cases. When ExcelML format is used the exported data is fetch directly from the database as in your case the values form the table column 31. On the other side when Biff format is used the exported content is generated based on the controls located into the TemplateColumn. In your case the two buttons which generate a False values into the excel cells. If you want to use Biff format and show the database data into the excel file a possible solution is to add a Label control which will be visible only in the exported file. I prepared a small sample and attached it to this forum post.

Regards,
Kostadin
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Vasssek
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Vasssek
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or