Skip to content

Commit 423f4e6

Browse files
committed
GriddlyExcelResult strips HTML from column captions
1 parent bfeccc1 commit 423f4e6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("3.2.15")]
19-
[assembly: AssemblyFileVersion("3.2.15")]
18+
[assembly: AssemblyVersion("3.2.16")]
19+
[assembly: AssemblyFileVersion("3.2.16")]
2020
//[assembly: AssemblyInformationalVersion("2.5-filters")]

Griddly.Mvc/GriddlyExcelResult.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Collections.Generic;
55
using System.Web.Mvc;
66
using System.Linq;
7+
using System.Web;
8+
using System.Text.RegularExpressions;
79

810
namespace Griddly.Mvc
911
{
@@ -24,6 +26,7 @@ public GriddlyExcelResult(IEnumerable<T> data, GriddlySettings settings, string
2426
_exportName = exportName;
2527
}
2628

29+
static readonly Regex _htmlMatch = new Regex(@"<[^>]*>", RegexOptions.Compiled);
2730
// static readonly Regex _aMatch = new Regex(@"<a\s[^>]*\s?href=""(.*?)"">(.*?)</a>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
2831

2932
public override void ExecuteResult(ControllerContext context)
@@ -42,7 +45,8 @@ public override void ExecuteResult(ControllerContext context)
4245

4346
for (int i = 0; i < columns.Count; i++)
4447
{
45-
ws.Cells[1, i + 1].Value = columns[i].Caption;
48+
string caption = HttpUtility.HtmlDecode(_htmlMatch.Replace(columns[i].Caption, "").Trim().Replace(" ", " "));
49+
ws.Cells[1, i + 1].Value = caption;
4650
ws.Cells[1, i + 1].Style.Font.Bold = true;
4751
}
4852

0 commit comments

Comments
 (0)