Export to CSV returns empty file

14 posts, 0 answers
  1. Rizwan
    Rizwan avatar
    30 posts
    Member since:
    Mar 2009

    Posted 17 Jun 2009 Link to this post

    Hi
      I am building a web application which contains list of grids in different area's. All have export options working fine but there is one grid which Export blank CSV even there is record. I have tried every possible option  but no output. Any help would be appreciated. this is the HTML code.

     

    <telerik:RadGrid ID="radGridSelectUser" runat="server" Skin="Office2007"

     

     

    AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"

     

     

    AllowMultiRowSelection="true" Width="99%" >

     

     

    <GroupingSettings CaseSensitive="false" />

     

     

    <ExportSettings OpenInNewWindow="true">

     

     

    <Pdf FontType="Link" PaperSize="A4" />

     

     

    <Excel Format="Html" />

     

     

    <Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" />

     

     

    </ExportSettings>

     

     

    <ClientSettings>

     

     

    <Selecting AllowRowSelect="true" />

     

     

    </ClientSettings>

     

     

     

    <MasterTableView >

     

     

    <PagerTemplate>

     

     

    <!-- This is my custom footer-->

     

     

     

     

     

    <uc1:gridFooter ID="gridFooter" runat="server" />

     

     

    </PagerTemplate>

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" DataField="Username" SortExpression="Username" FilterControlWidth="95%" >

     

     

    <ItemTemplate>

     

     

    <asp:LinkButton runat="server" ID="lnkUserName" OnClick="lnkUserName_Click" ToolTip='<%# DataBinder.Eval(Container.DataItem,"Username")%>' CommandName="SELECT" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"UserId")%>' Text='<%# DataBinder.Eval(Container.DataItem,"Username")%>'></asp:LinkButton>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    </MasterTableView>

     

     

     

    </telerik:RadGrid>

     



    Code Behind on Button Click

    // There are mostly records between 2- 10

    radGridSelectUser.ExportSettings.ExportOnlyData =

    true;

     

    radGridSelectUser.ExportSettings.IgnorePaging =

    true;

     

    radGridSelectUser.ExportSettings.OpenInNewWindow =

    true;

     

    radGridSelectUser.MasterTableView.ExportToCSV();


    Best Regards

     

    Rizwan Bashir

     

  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 17 Jun 2009 Link to this post

    Hi Rizwan,

    I suggest you using the tips from this section of the documentation (paragraph 'Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data') to export the template column.

    All the best,
    Pavlina
    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.
  3. Rizwan
    Rizwan avatar
    30 posts
    Member since:
    Mar 2009

    Posted 17 Jun 2009 Link to this post

    Hi
       Thanks for the link, I have added another column in the grid

    <

     

    telerik:GridBoundColumn DataField="Username" HeaderText="Username" AllowSorting="true" Display="true" ></telerik:GridBoundColumn>

     



    this is GroupBound column which must be exported but even then I get CSV with headers only.i-e Username , Username   and thats  it.
    so if it does not find the data for first column then it must display the second one but nothing here.

    Any other options ?

    Best Regards
    RIzwan Bashir
  4. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 17 Jun 2009 Link to this post

    Hi Rizwan,

    I followed your scenario in order to replicate the issue but to no avail. Please find attached a simple runnable application which is working as expected. Give it a try and let me know what is the difference in your case.

    Looking forward for your reply.

    All the best,
    Pavlina
    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.
  5. Rizwan
    Rizwan avatar
    30 posts
    Member since:
    Mar 2009

    Posted 18 Jun 2009 Link to this post

    hi
      I am unable to replicate my problem on your sample page neither able to fix it on my application but there are 2 issues which arise on this page and may be useful for you as I am not facing these problems on my main application.
    You can download the source from
    http://www.alm-soft.com/Rizwan/135059_export-to-csv.zip

    I have removed the telerik files from bin which you can put back before playing with it.

    problems on newly added grid
    1)  If you click next on navigation then it will not work but if you will click on page "2" then it will.
    2) if you export the grid to CSV  then file name should be "Username.csv" but it would be something like Username324234.csv

    these problems do not appear in my orignal application but appear here so I thought to brought them in your attention.

    Best Regards
    Rizwan Bashir
  6. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 18 Jun 2009 Link to this post

    Hello Rizwan,

    Could you please verify that this is the correct link, because I was not able to open it?
    It will be best if you can open a formal support ticket and send us a simple running project  demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

    Best wishes,
    Pavlina
    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.
  7. Rizwan
    Rizwan avatar
    30 posts
    Member since:
    Mar 2009

    Posted 18 Jun 2009 Link to this post

    hi
       The link is still alive but it is case sensitive so please copy paste this
    http://www.alm-soft.com/Rizwan/135059_export-to-csv.zip

    in browser and it should work. As far the issue is concerned, I am facing this only on grid in my entire application so reproducing it is not a piece of cake :-) even I am not able to recreate it on other controls. May be rebuilding the contrl from scratch would resolve the problem.
      I shall try it again on another application and if I manage to reproduce it then I shall get the ticket and will update here as well.

    Best Regards
    Rizwan Bashir

  8. Maulik
    Maulik avatar
    1 posts
    Member since:
    Jun 2009

    Posted 18 Jun 2009 Link to this post

    Hi,

    I have similar problem.

    When I export to Word, Excel or PDF it works fine.

    With CSV it generates file with only header information.

    I am trying to exprot grid which is not visible. If i make visible="true" it works fine.

    Is there a way to make it work with visible="false"

  9. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 22 Jun 2009 Link to this post

    Hi Maulik,

    Please find attached a modified project that demonstrates the needed approach. Note that Simple data-binding through the DataBind() method can be used in simple scenarios which does not require complex operations like paging. For advanced features such as paging, RadGrid must be bound through the NeedDataSource event.

    Additionally, as you can see from the attached screenshot the name of the CSV file is "Username.csv".

    Best wishes,
    Pavlina
    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.
  10. Jeff
    Jeff avatar
    4 posts
    Member since:
    Apr 2019

    Posted 03 Jun in reply to Pavlina Link to this post

    My page is using an on-page data source.

    But my export to excel isn't working.

    Is this the reason?

  11. Attila Antal
    Admin
    Attila Antal avatar
    426 posts

    Posted 04 Jun Link to this post

    Hi Jeff,

    There could be different reasons, depending on the grid configuration and data binding.

    Can you please elaborate on the "on-page data source"? 
    • Are you referring to, binding data during Page Load?
    • Is data bound on client, meaning that the Data comes as a JSON string -> JavaScript object and is bound to RadGrid on client?
    • Is there any custom logic that is supposed to handle the exporting manually?

    It would be very helpful if you could share more details.

    Here are some demos and samples regarding the export functionality:

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  12. Jeff
    Jeff avatar
    4 posts
    Member since:
    Apr 2019

    Posted 04 Jun in reply to Attila Antal Link to this post

    The application uses Telerik.Web.UI, version 2014.2.724.40.

    The web page has an embedded ObjectDataSource, which calls a method in the code behind, which in turn calls a stored procedure to return the data set.

    The Telerik RadGrid has both ShowExportToExcelButton and ShowExportToCsvButton set to "true".

    When the export to excel button is pressed, I want all data from the Dataset associated with the RadGrid exported to excel, not just what's on the grid.

    When extract type is HTML, I get an empty excel spread sheet.  When extract type is ExcelML, I get an error about advanced binding.  I don't care if the extract is in HTML or EcelML, I just want the user to be able to pull a copy of the dataset.

    I'd attach a code extract, but only images are allowed.

     

  13. Attila Antal
    Admin
    Attila Antal avatar
    426 posts

    Posted 05 Jun Link to this post

    Hi Jeff,

    To continue the investigation on this case, I suggest that you open a formal support ticket and share the details with us. The system will allow you to attach almost any kind if compressed in a zip file.

    The best would be if you could send us a runnable sample that produces the error, though, sending only the aspx page and the its code behind file would also be enough to get an idea about the scenario. 

    Also, please mention the link to this forum in the support ticket as a reference: Export to CSV returns empty file

    Once we found a solution, we will share it in this forum thread to to make it available for the community.

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  14. Jeff
    Jeff avatar
    4 posts
    Member since:
    Apr 2019

    Posted 05 Jun Link to this post

    I stole some code from CodeProject to do it in the code behind.
Back to Top