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

[Solved] Export Excel Server.Execute

1 Answer 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 20 Oct 2009, 06:24 PM
Hello,

 I am currently exporting a aspx page to excel using the below code. This page has multiple RadGrids on it with Headers and Footers. The Problem I am having is that when Exporting to Excel it is putting the Footer row ABOVE the rad grid instead of at the Bottom. Is there a way of correcting this or a work around? Thank you.

This is On Page Load of a GenerateReport.aspx Page which gets called by the ASPX page which is what I am trying to export to excel.

 
            Response.Clear()  
            Response.Charset = "" 
            ''set the response mime type for excel  
            Response.ContentType = "application/vnd.ms-excel" 
 
            HttpContext.Current.Response.AddHeader("content-disposition""attachment;filename=1.xls")  
 
            Dim sw As New StringWriter  
            Server.Execute(Session("ReportFile"), sw)  
 
            Response.Write(sw.ToString.Replace("<div""<span").Replace("</div""</span").Replace("<input id=""ctl00_PageContent", "<span id=""ctl00_PageContent"))  
            Response.End() 

This is one of the RadGrids currently on a aspx page which I am trying to export by doing the server.execute Above.

          
         <telerik:RadGrid ID="dgMonth" runat="server" ShowGroupPanel="False" RecordType="Deposit" AutoGenerateColumns="True" EnableEmbeddedskins="false" 
                RecordCountString="Total Record Count: {0}" Width="700px" RecordCountCssClass="" InsertMode="1"  InsertInDialogWindow="0" EnableAJAXLoadingTemplate="True"   
                DataActiveField="Active" BorderWidth="1px" ShowFooter="True"  GridLines="None" PagerStyleVisible="False" FooterStyle-BackColor="AliceBlue" > 
            <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" Visible="False"   /> 
            <ClientSettings AllowDragToGroup="True"></ClientSettings> 
            <MasterTableView CommandItemDisplay="Top" ShowHeader="True" Width="100%" DataKeyNames="MonthlyDate" ShowFooter="true" EditMode="InPlace">  
                 <EditFormSettings> 
                    <PopUpSettings ScrollBars="None"></PopUpSettings> 
                </EditFormSettings> 
                <CommandItemTemplate> 
                    <asp:LinkButton ID="lnkInsert" runat="server" Visible="false" CommandName="InitInsert" CausesValidation="false"<img style="border:0px" alt="" src="../images/AddRecord.gif" />Add New Interim Deposit</asp:LinkButton> 
                </CommandItemTemplate> 
                <CommandItemSettings AddNewRecordImageUrl="AddRecord.gif" RefreshImageUrl="Refresh.gif">  
                </CommandItemSettings> 
                  <FooterStyle BackColor="White" ForeColor="Black" Font-Size="12pt"   
                        Font-Bold="False"   HorizontalAlign="Right" /> 
 
            </MasterTableView> 
            <HeaderContextMenu EnableEmbeddedSkins="False" EnableTheming="True">  
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            </HeaderContextMenu> 
            <FilterMenu EnableEmbeddedSkins="False" EnableTheming="True">  
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            </FilterMenu> 
        </telerik:RadGrid> 


1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 23 Oct 2009, 02:44 PM
Hello Ryan,

I suggest you utilize the built-in export to Excel feature of RadGrid for ASP.NET AJAX presented here:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx

Thus the grid footer should be placed below its data in the resulting Excel file.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or