Skip to content

Commit

Permalink
Fix for Dijji#8
Browse files Browse the repository at this point in the history
- No replacement about \r \n, instead the column is wrapped by "".
- A doublequote is replaced with two doublequotes.
- No commna replaced because it is not necessary.
  • Loading branch information
halueda authored Apr 18, 2019
1 parent 8de40db commit 15c1f2b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions XstFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,11 @@ private void AddCsvValue(StringBuilder sb, string value, ref bool hasValue)

if (value != null)
{
value = value.Replace("\r\n", "; ").Replace("\r", "; ").Replace("\n", "; ");
if (value.Contains(','))
if (value.Contains(',') || value.Contains('"') || value.Contains("\n") || value.Contains("\n") )
{
// We need to quote the value, and therefore get rid of quotes in it
// Excel is also fooled by spaces after embedded commas
var val = value.Replace("\"", "'");
while (val.Contains(", "))
val = val.Replace(", ", ",");
var val = value.Replace("\"", "\"\"");
sb.Append("\"");
sb.Append(EnforceCsvValueLengthLimit(val));
sb.Append("\"");
Expand Down

0 comments on commit 15c1f2b

Please sign in to comment.