Skip to content

Commit

Permalink
Fix exception when invalid XML chars are included in Excel export (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavnavar committed Apr 25, 2024
1 parent 4efeaf9 commit 60471c0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion GridBlazor/ExcelWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ namespace GridBlazor
{
public class ExcelCell
{
public string Content { get; set; }
private string _content;

public string Content {
get { return _content; }
set {
_content = RemoveInvalidXmlChars(value);
}
}
public int ColumnIndex { get; set; }
public int RowIndex { get; set; }
public int ColSpan { get; set; }
Expand Down Expand Up @@ -46,6 +53,11 @@ public ExcelCell(string value, Type type = null)
else
Type = CellValues.InlineString;
}

private string RemoveInvalidXmlChars(string content)
{
return new string(content.Where(ch => System.Xml.XmlConvert.IsXmlChar(ch)).ToArray());
}
}

public class ExcelStatus
Expand Down

0 comments on commit 60471c0

Please sign in to comment.