Export

9 posts, 0 answers
  1. Raymond
    Raymond avatar
    53 posts
    Member since:
    Aug 2007

    Posted 16 Oct 2008 Link to this post

    I try to export a simple grid without any success

    to excel - it only give me the current page when ignorpaging = false and none when ignorepaging = true

    to pdf - it give me an error of unsupported file type.

    How do I resolve this?
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Oct 2008 Link to this post

    Hello Raymond,

    Can you provide a bit more info how to reproduce this? Or can you reproduce this on our examples:
    http://demos.telerik.com/aspnet/Prometheus/Grid/Examples/GeneralFeatures/Exporting/DefaultCS.aspx
    http://demos.telerik.com/aspnet/Prometheus/Grid/Examples/GeneralFeatures/PdfExport/DefaultCS.aspx

    Kind regards,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2008 Link to this post

    Hi Raymond,

    Try removing the paging functionality for the Grid in the Export button's click event and see whether it is working.

    CS:
     protected void Button1_Click(object sender, EventArgs e) 
        { 
            RadGrid1.AllowPaging = false
            RadGrid1.Rebind(); 
            RadGrid1.ExportSettings.OpenInNewWindow = true
            RadGrid1.MasterTableView.ExportToExcel(); 
        } 



    Thanks
    Shinu.
  5. Raymond
    Raymond avatar
    53 posts
    Member since:
    Aug 2007

    Posted 17 Oct 2008 Link to this post

    The suggested solution is not working too.

    The page is as follows

     

    <telerik:RadGrid ID="rgAccountXact" DataSourceID="odsAccountXact" AllowSorting="True"

     

     

    runat="server" OnItemCreated="rgAccountXact_ItemCreated" OnItemDataBound="rgAccountXact_ItemDataBound"

     

     

    AutoGenerateColumns="False" AllowPaging="True" PageSize="19"

     

     

    CellPadding="5" CellSpacing="5" Skin="Office2007">

     

     

    <PagerStyle Mode="NextPrevAndNumeric" />

     

     

    <MasterTableView ShowFooter="False" Width="100%" DataKeyNames="idAcctXact" CommandItemDisplay="Top">

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">

     

     

    <ItemStyle HorizontalAlign="Center" />

     

     

    <ItemTemplate>

     

     

    <asp:ImageButton ID="ibEdit" runat="server" ImageUrl="~/Images/Edit.gif" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridTemplateColumn UniqueName="AcctDate" HeaderText="Date" SortExpression="AcctDate">

     

     

    <ItemTemplate>

     

    <%

    # FormatDate( Eval("AcctDate").ToString())%>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="Beneficiary" HeaderText="Shopper">

     

     

    <ItemTemplate>

     

    <%

    # Eval("Beneficiary")%>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" UniqueName="Amount"

     

     

    ItemStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />

     

     

    <telerik:GridBoundColumn DataField="Notes" HeaderText="Note" UniqueName="Notes" />

     

     

    <telerik:GridTemplateColumn UniqueName="TemplateDeleteColumn">

     

     

    <ItemStyle HorizontalAlign="Center" />

     

     

    <ItemTemplate>

     

     

    <asp:ImageButton ID="ibDelete" runat="server" ImageUrl="~/Images/trash.gif" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    <CommandItemTemplate>

     

     

    <div style="padding:10px 0px;">

     

     

    &nbsp;&nbsp;&nbsp;

     

     

    <asp:ImageButton ID="ibAdd" runat="server" AlternateText="Add new Account xact" ImageUrl="~/Images/Add.gif"

     

     

    OnClientClick="return ShowInsertXact();" />

     

     

    &nbsp&nbsp;

     

     

    <asp:LinkButton ID="lbAdd" runat="server" Text="New Account Xact" ToolTip="Add New Account Xact"

     

     

    OnClientClick="return ShowInsertXact();" />

     

     

    </div>

     

     

    </CommandItemTemplate>

     

     

    </MasterTableView>

     

     

    <ClientSettings EnableRowHoverStyle="true">

     

     

    <Selecting AllowRowSelect="true" />

     

     

    </ClientSettings>

     

     

    </telerik:RadGrid>

     

     

     

    <asp:ObjectDataSource ID="odsAccountXact" runat="server" TypeName="RaymondApp.AccountXact"

     

     

    SelectMethod="Search" SelectCountMethod="SearchCount" EnablePaging="True" SortParameterName="sortBy"

     

     

    MaximumRowsParameterName="pageSize" StartRowIndexParameterName="firstRow"

     

     

    OldValuesParameterFormatString="original_{0}">

     

     

    <SelectParameters>

     

     

    <asp:Parameter Name="firstRow" Type="Int32" DefaultValue="0" />

     

     

    <asp:Parameter Name="pageSize" Type="Int32" DefaultValue="10" />

     

     

    <asp:Parameter Name="sortBy" Type="String" DefaultValue="AcctDate DESC" />

     

     

    <asp:Parameter Name="idAcctXact" Type="Int32" />

     

     

    <asp:Parameter Name="acctDate" Type="DateTime" />

     

     

    <asp:Parameter Name="idGroupType" Type="Int32" />

     

     

    <asp:Parameter Name="xactType" Type="String" />

     

     

    <asp:Parameter Name="beneficiary" Type="String" />

     

     

    <asp:Parameter Name="amount" Type="Decimal" />

     

     

    <asp:Parameter Name="idAccount" Type="Int32" DefaultValue="1" />

     

     

    <asp:Parameter Name="source" Type="String" />

     

     

    <asp:Parameter Name="relatedID" Type="Int32" />

     

     

    <asp:Parameter Name="notes" Type="String" />

     

     

    <asp:Parameter Name="checkNo" Type="String" />

     

     

    <asp:Parameter Name="reconcile" Type="Boolean" />

     

     

    <asp:Parameter Name="reconciled" Type="Int32" />

     

     

    <asp:Parameter Name="dateReconciled" Type="DateTime" />

     

     

    <asp:Parameter Name="formatType" Type="String" />

     

     

    </SelectParameters>

     

     

    </asp:ObjectDataSource>

     

    <

     

    asp:Button ID="btn" runat="server" Text="export" OnClick="ibExcel_Click" />


    code behind on click event

     

     

    protected void ibExcel_Click(object sender, EventArgs e)

     

    {

     

    try

     

     

     

     

    {

     

    //rgTools.PageSize = rgTools.MasterTableView.VirtualItemCount;

     

     

     

     

    rgAccountXact.AllowPaging =

    false;

     

    rgAccountXact.Rebind();

    rgAccountXact.ExportSettings.OpenInNewWindow =

    true;

     

     

    //rgAccountXact.ExportSettings.IgnorePaging = true;

     

     

     

     

     

    //rgAccountXact.ExportSettings.ExportOnlyData = true;

     

     

     

     

     

    //rgTools.MasterTableView.ExportToPdf();

     

     

     

     

     

    ////ConfigureExport();

     

     

     

     

    rgAccountXact.MasterTableView.ExportToExcel();

     

    //rgTools.AllowPaging = true;

     

     

     

     

     

    //rgTools.Rebind();

     

     

     

     

    }

     

    catch (Exception ex)

     

    {

    }

    }

    I cannot export any in pdf (no matter the ignorpaging is set or not) and in excel (only work on ignorepaging = false)

  6. Raymond
    Raymond avatar
    53 posts
    Member since:
    Aug 2007

    Posted 17 Oct 2008 Link to this post

    The suggested solution is not working too.

    The page is as follows

     

    <telerik:RadGrid ID="rgAccountXact" DataSourceID="odsAccountXact" AllowSorting="True"

     

     

    runat="server" OnItemCreated="rgAccountXact_ItemCreated" OnItemDataBound="rgAccountXact_ItemDataBound"

     

     

    AutoGenerateColumns="False" AllowPaging="True" PageSize="19"

     

     

    CellPadding="5" CellSpacing="5" Skin="Office2007">

     

     

    <PagerStyle Mode="NextPrevAndNumeric" />

     

     

    <MasterTableView ShowFooter="False" Width="100%" DataKeyNames="idAcctXact" CommandItemDisplay="Top">

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">

     

     

    <ItemStyle HorizontalAlign="Center" />

     

     

    <ItemTemplate>

     

     

    <asp:ImageButton ID="ibEdit" runat="server" ImageUrl="~/Images/Edit.gif" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridTemplateColumn UniqueName="AcctDate" HeaderText="Date" SortExpression="AcctDate">

     

     

    <ItemTemplate>

     

    <%

    # FormatDate( Eval("AcctDate").ToString())%>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="Beneficiary" HeaderText="Shopper">

     

     

    <ItemTemplate>

     

    <%

    # Eval("Beneficiary")%>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" UniqueName="Amount"

     

     

    ItemStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />

     

     

    <telerik:GridBoundColumn DataField="Notes" HeaderText="Note" UniqueName="Notes" />

     

     

    <telerik:GridTemplateColumn UniqueName="TemplateDeleteColumn">

     

     

    <ItemStyle HorizontalAlign="Center" />

     

     

    <ItemTemplate>

     

     

    <asp:ImageButton ID="ibDelete" runat="server" ImageUrl="~/Images/trash.gif" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    <CommandItemTemplate>

     

     

    <div style="padding:10px 0px;">

     

     

    &nbsp;&nbsp;&nbsp;

     

     

    <asp:ImageButton ID="ibAdd" runat="server" AlternateText="Add new Account xact" ImageUrl="~/Images/Add.gif"

     

     

    OnClientClick="return ShowInsertXact();" />

     

     

    &nbsp&nbsp;

     

     

    <asp:LinkButton ID="lbAdd" runat="server" Text="New Account Xact" ToolTip="Add New Account Xact"

     

     

    OnClientClick="return ShowInsertXact();" />

     

     

    </div>

     

     

    </CommandItemTemplate>

     

     

    </MasterTableView>

     

     

    <ClientSettings EnableRowHoverStyle="true">

     

     

    <Selecting AllowRowSelect="true" />

     

     

    </ClientSettings>

     

     

    </telerik:RadGrid>

     

     

     

    <asp:ObjectDataSource ID="odsAccountXact" runat="server" TypeName="RaymondApp.AccountXact"

     

     

    SelectMethod="Search" SelectCountMethod="SearchCount" EnablePaging="True" SortParameterName="sortBy"

     

     

    MaximumRowsParameterName="pageSize" StartRowIndexParameterName="firstRow"

     

     

    OldValuesParameterFormatString="original_{0}">

     

     

    <SelectParameters>

     

     

    <asp:Parameter Name="firstRow" Type="Int32" DefaultValue="0" />

     

     

    <asp:Parameter Name="pageSize" Type="Int32" DefaultValue="10" />

     

     

    <asp:Parameter Name="sortBy" Type="String" DefaultValue="AcctDate DESC" />

     

     

    <asp:Parameter Name="idAcctXact" Type="Int32" />

     

     

    <asp:Parameter Name="acctDate" Type="DateTime" />

     

     

    <asp:Parameter Name="idGroupType" Type="Int32" />

     

     

    <asp:Parameter Name="xactType" Type="String" />

     

     

    <asp:Parameter Name="beneficiary" Type="String" />

     

     

    <asp:Parameter Name="amount" Type="Decimal" />

     

     

    <asp:Parameter Name="idAccount" Type="Int32" DefaultValue="1" />

     

     

    <asp:Parameter Name="source" Type="String" />

     

     

    <asp:Parameter Name="relatedID" Type="Int32" />

     

     

    <asp:Parameter Name="notes" Type="String" />

     

     

    <asp:Parameter Name="checkNo" Type="String" />

     

     

    <asp:Parameter Name="reconcile" Type="Boolean" />

     

     

    <asp:Parameter Name="reconciled" Type="Int32" />

     

     

    <asp:Parameter Name="dateReconciled" Type="DateTime" />

     

     

    <asp:Parameter Name="formatType" Type="String" />

     

     

    </SelectParameters>

     

     

    </asp:ObjectDataSource>

     

    <

     

    asp:Button ID="btn" runat="server" Text="export" OnClick="ibExcel_Click" />


    code behind on click event

     

     

    protected void ibExcel_Click(object sender, EventArgs e)

     

    {

     

    try

     

     

     

     

    {

     

    //rgTools.PageSize = rgTools.MasterTableView.VirtualItemCount;

     

     

     

     

    rgAccountXact.AllowPaging =

    false;

     

    rgAccountXact.Rebind();

    rgAccountXact.ExportSettings.OpenInNewWindow =

    true;

     

     

    //rgAccountXact.ExportSettings.IgnorePaging = true;

     

     

     

     

     

    //rgAccountXact.ExportSettings.ExportOnlyData = true;

     

     

     

     

     

    //rgTools.MasterTableView.ExportToPdf();

     

     

     

     

     

    ////ConfigureExport();

     

     

     

     

    rgAccountXact.MasterTableView.ExportToExcel();

     

    //rgTools.AllowPaging = true;

     

     

     

     

     

    //rgTools.Rebind();

     

     

     

     

    }

     

    catch (Exception ex)

     

    {

    }

    }

    I cannot export any in pdf (no matter the ignorpaging is set or not) and in excel (only work on ignorepaging = false)

  7. Raymond
    Raymond avatar
    53 posts
    Member since:
    Aug 2007

    Posted 17 Oct 2008 Link to this post

    The suggested solution is not working too.

    The page is as follows

     

    <telerik:RadGrid ID="rgAccountXact" DataSourceID="odsAccountXact" AllowSorting="True"

     

     

    runat="server" OnItemCreated="rgAccountXact_ItemCreated" OnItemDataBound="rgAccountXact_ItemDataBound"

     

     

    AutoGenerateColumns="False" AllowPaging="True" PageSize="19"

     

     

    CellPadding="5" CellSpacing="5" Skin="Office2007">

     

     

    <PagerStyle Mode="NextPrevAndNumeric" />

     

     

    <MasterTableView ShowFooter="False" Width="100%" DataKeyNames="idAcctXact" CommandItemDisplay="Top">

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">

     

     

    <ItemStyle HorizontalAlign="Center" />

     

     

    <ItemTemplate>

     

     

    <asp:ImageButton ID="ibEdit" runat="server" ImageUrl="~/Images/Edit.gif" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridTemplateColumn UniqueName="AcctDate" HeaderText="Date" SortExpression="AcctDate">

     

     

    <ItemTemplate>

     

    <%

    # FormatDate( Eval("AcctDate").ToString())%>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="Beneficiary" HeaderText="Shopper">

     

     

    <ItemTemplate>

     

    <%

    # Eval("Beneficiary")%>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

     

    <telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" UniqueName="Amount"

     

     

    ItemStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />

     

     

    <telerik:GridBoundColumn DataField="Notes" HeaderText="Note" UniqueName="Notes" />

     

     

    <telerik:GridTemplateColumn UniqueName="TemplateDeleteColumn">

     

     

    <ItemStyle HorizontalAlign="Center" />

     

     

    <ItemTemplate>

     

     

    <asp:ImageButton ID="ibDelete" runat="server" ImageUrl="~/Images/trash.gif" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    <CommandItemTemplate>

     

     

    <div style="padding:10px 0px;">

     

     

    &nbsp;&nbsp;&nbsp;

     

     

    <asp:ImageButton ID="ibAdd" runat="server" AlternateText="Add new Account xact" ImageUrl="~/Images/Add.gif"

     

     

    OnClientClick="return ShowInsertXact();" />

     

     

    &nbsp&nbsp;

     

     

    <asp:LinkButton ID="lbAdd" runat="server" Text="New Account Xact" ToolTip="Add New Account Xact"

     

     

    OnClientClick="return ShowInsertXact();" />

     

     

    </div>

     

     

    </CommandItemTemplate>

     

     

    </MasterTableView>

     

     

    <ClientSettings EnableRowHoverStyle="true">

     

     

    <Selecting AllowRowSelect="true" />

     

     

    </ClientSettings>

     

     

    </telerik:RadGrid>

     

     

     

    <asp:ObjectDataSource ID="odsAccountXact" runat="server" TypeName="RaymondApp.AccountXact"

     

     

    SelectMethod="Search" SelectCountMethod="SearchCount" EnablePaging="True" SortParameterName="sortBy"

     

     

    MaximumRowsParameterName="pageSize" StartRowIndexParameterName="firstRow"

     

     

    OldValuesParameterFormatString="original_{0}">

     

     

    <SelectParameters>

     

     

    <asp:Parameter Name="firstRow" Type="Int32" DefaultValue="0" />

     

     

    <asp:Parameter Name="pageSize" Type="Int32" DefaultValue="10" />

     

     

    <asp:Parameter Name="sortBy" Type="String" DefaultValue="AcctDate DESC" />

     

     

    <asp:Parameter Name="idAcctXact" Type="Int32" />

     

     

    <asp:Parameter Name="acctDate" Type="DateTime" />

     

     

    <asp:Parameter Name="idGroupType" Type="Int32" />

     

     

    <asp:Parameter Name="xactType" Type="String" />

     

     

    <asp:Parameter Name="beneficiary" Type="String" />

     

     

    <asp:Parameter Name="amount" Type="Decimal" />

     

     

    <asp:Parameter Name="idAccount" Type="Int32" DefaultValue="1" />

     

     

    <asp:Parameter Name="source" Type="String" />

     

     

    <asp:Parameter Name="relatedID" Type="Int32" />

     

     

    <asp:Parameter Name="notes" Type="String" />

     

     

    <asp:Parameter Name="checkNo" Type="String" />

     

     

    <asp:Parameter Name="reconcile" Type="Boolean" />

     

     

    <asp:Parameter Name="reconciled" Type="Int32" />

     

     

    <asp:Parameter Name="dateReconciled" Type="DateTime" />

     

     

    <asp:Parameter Name="formatType" Type="String" />

     

     

    </SelectParameters>

     

     

    </asp:ObjectDataSource>

     

    <

     

    asp:Button ID="btn" runat="server" Text="export" OnClick="ibExcel_Click" />


    code behind on click event

     

     

    protected void ibExcel_Click(object sender, EventArgs e)

     

    {

     

    try

     

     

     

     

    {

     

    //rgTools.PageSize = rgTools.MasterTableView.VirtualItemCount;

     

     

     

     

    rgAccountXact.AllowPaging =

    false;

     

    rgAccountXact.Rebind();

    rgAccountXact.ExportSettings.OpenInNewWindow =

    true;

     

     

    //rgAccountXact.ExportSettings.IgnorePaging = true;

     

     

     

     

     

    //rgAccountXact.ExportSettings.ExportOnlyData = true;

     

     

     

     

     

    //rgTools.MasterTableView.ExportToPdf();

     

     

     

     

     

    ////ConfigureExport();

     

     

     

     

    rgAccountXact.MasterTableView.ExportToExcel();

     

    //rgTools.AllowPaging = true;

     

     

     

     

     

    //rgTools.Rebind();

     

     

     

     

    }

     

    catch (Exception ex)

     

    {

    }

    }

    I cannot export any in pdf (no matter the ignorpaging is set or not) and in excel (only work on ignorepaging = false)

  8. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 20 Oct 2008 Link to this post

    Hello Raymond,

    Unfortunately I don't see anything in your code that might cause exporting of RadGrid to fail.
    For your convenience I prepared a small example demonstrating RadGrid export to Excel and Pdf. Part of the RadGrid columns definition is as yours posted in this forum thread.

    Please find the project and give it a try. If you are still having issues with your project, I suggest you open a formal support ticket and send us a runnable example that replicates the issue. Thus we'll be able to help you further.

    Best regards,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Omarr
    Omarr avatar
    24 posts
    Member since:
    Sep 2008

    Posted 24 Oct 2008 Link to this post

    Try this function. Change the pagesize to the total no. of rows of the datatable. This will solve your problem.

    public void Export2Excel(Telerik.Web.UI.RadGrid gridViewName, int TotalCount, string WorkBookName)
    {
     
     gridViewName.MasterTableView.PageSize = TotalCount;
     gridViewName.ExportSettings.OpenInNewWindow = true;
     gridViewName.ExportSettings.FileName = WorkBookName;
     gridViewName.ExportSettings.IgnorePaging = true;
     gridViewName.MasterTableView.ExportToExcel();

    }

     

     

  10. Lan
    Lan avatar
    1 posts
    Member since:
    Sep 2008

    Posted 02 Nov 2011 Link to this post

    If you use object datasource, try this

    protected void ods_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
    if (0 == e.Arguments.MaximumRows)
    {
    e.Arguments.MaximumRows = int.MaxValue;
    }

    }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017