Last Updated: 13 Mar 2019 16:21 by ADMIN
Release 2018.3.1016
Created on: 09 Apr 2018 11:54
Category: GridView
Type: Bug Report
FIX. RadGridView - ArgumentException is thrown when exporting characters not supported in XML
How to reproduce: 
public partial class Form1 : Form
    public Form1()

        ThemeResolutionService.AllowAnimations = false;
        this.radGridView1.DataSource = this.GetData();

    private DataTable GetData()
        DataTable dt = new DataTable();
        dt.Columns.Add("Id", typeof(int));
        dt.Columns.Add("Name", typeof(string));
        dt.Rows.Add(1, "\u0002x09");
        for (int i = 1; i < 10; i++)
            dt.Rows.Add(i, "name");

        return dt;

    private void radButton1_Click(object sender, EventArgs e)
        GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
        spreadExporter.FileExportMode = FileExportMode.CreateOrOverrideFile;
        SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
        spreadExporter.RunExport(@"..\..\exported-file.xlsx", exportRenderer);

ArgumentException with clarification similar to  "'\u001f', hexadecimal value 0x1F, is an invalid character." is thrown when trying to export document containing characters which are not supported in XML document - such as some control characters like 0x00, 0x1F, 0x1B, etc. Such characters are described in the XML specification here:

Although the escaped strings are not supported (see ), the library could prevent the exception and export the document successfully by skipping such characters.

Workaround: remove such characters before the export. Check the following StackOverflow answer for some ideas on code for replacing the characters: