Export to CSV - empty string or NULL values exported as single space

4 posts, 0 answers
  1. Greg S
    Greg S avatar
    8 posts
    Member since:
    Jul 2015

    Posted 04 Aug Link to this post

    I'm exporting a grid to CSV. I've noticed when a value is null or blank, the resulting value is space. Using <ExportSettings Csv-EncloseDataWithQuotes="true" /> a blank value shows up as " " vs. "".

    Is there a setting that can change this behavior? The files are being uploaded to another 3rd party tool, and a single space is not a valid option.

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 09 Aug Link to this post

    Hello Greg,

    I have tested the behavior in question with our latest version and there is no empty space in the exported CSV file. Can you please test with our latest versions and see if the issue still persists?

    Looking forward to your reply.


    Regards,
    Konstantin Dikov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Greg S
    Greg S avatar
    8 posts
    Member since:
    Jul 2015

    Posted 15 Aug in reply to Konstantin Dikov Link to this post

    Well - this fixed the empty string problem, but created a new problem.Date data types are being handled differently in the Excel export. After this update, sql columns defined as "datetime" are being exported as numbers. You can reformat the numbers as dates in Excel, but that's a huge hassle to do for multiple columns every time you export. Before this update, users would not have to do this.

    Is there a way to configure the radgrid Excel export so it formats dates?

     

     

  5. Greg S
    Greg S avatar
    8 posts
    Member since:
    Jul 2015

    Posted 15 Aug in reply to Greg S Link to this post

    I figured it out. 

    I was running the code below and changing the formatting of every cell to "@". This is because my page is actually a generic report processor, and if the data started with a character that Excel interpreted as a function (e.g. "-", "+", etc.) then it would cause problems. The previous version of the controls however still exported a date in a date format however. After upgrading to the newest version however, dates were exported as their Excel numeric equivalent. 

    protected void radGrid_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e)
     {
         foreach (var row in e.ExportStructure.Tables[0].Rows)
             foreach (var cell in row.Cells)
                 cell.Format = "@";
     }
    I added a check for  a datetime data type before changing the format and this fixed my scenario.

Back to Top