Approved
Last Updated: 27 Apr 2018 05:52 by ADMIN
ADMIN
Hristo
Created on: 09 Apr 2018 11:54
Category: GridView
Type: Bug Report
1
FIX. RadGridView - ArgumentException is thrown when exporting characters not supported in XML
How to reproduce: 
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        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: https://www.w3.org/TR/xml/#charsets.

Although the escaped strings are not supported (see  https://feedback.telerik.com/Project/184/Feedback/Details/190228 ), 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: http://stackoverflow.com/a/14323524/259206
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments