diff --git a/Blazor/Blazor/Blazor.csproj b/Blazor/Blazor/Blazor.csproj index 62be3fa..ea3a619 100644 --- a/Blazor/Blazor/Blazor.csproj +++ b/Blazor/Blazor/Blazor.csproj @@ -14,33 +14,34 @@ - - - - + + + + - + - - - - - - - - - - - - - - <_ContentIncludedByDefault Remove="Pages\_Layout.cshtml" /> - - - - + + + + + + + + + + + + + + + <_ContentIncludedByDefault Remove="Pages\_Layout.cshtml" /> + + + + diff --git a/Blazor/Blazor/Pages/Questions/Questions.razor.cs b/Blazor/Blazor/Pages/Questions/Questions.razor.cs index 865bde5..b5e8df7 100644 --- a/Blazor/Blazor/Pages/Questions/Questions.razor.cs +++ b/Blazor/Blazor/Pages/Questions/Questions.razor.cs @@ -13,6 +13,7 @@ using Blazored.Modal; using System.Text.RegularExpressions; using Blazor.Components; using Microsoft.Extensions.Localization; +using SuperConvert.Extensions; namespace Blazor.Pages.Questions; @@ -110,15 +111,9 @@ public partial class Questions StringBuilder sb = new StringBuilder(); HttpResponseMessage response = await Http.GetAsync(API.API_URL+"questionsExport/"+API.TOKEN); var json = await response.Content.ReadAsStringAsync(); - using (var jsonFile = ChoJSONReader.LoadText(json)) - { - using (var csvFile = new ChoCSVWriter(sb).WithFirstLineHeader()) - { - csvFile.Write(jsonFile); - } - } - - var sentFile = new MemoryStream(Encoding.Unicode.GetBytes(sb.ToString())); + byte[] csv = json.ToCsv(';'); + string csvString = Encoding.Unicode.GetString(csv); + var sentFile = new MemoryStream(Encoding.Unicode.GetBytes(csvString)); using (var streamRef = new DotNetStreamReference(stream: sentFile)) { await IJSRuntime.InvokeVoidAsync("downloadFileFromStream", "data.csv", streamRef); @@ -131,9 +126,10 @@ public partial class Questions { await e.File.OpenReadStream().CopyToAsync(ms); var bytes = ms.ToArray(); - string s = Encoding.UTF8.GetString(bytes); + string s = Encoding.Unicode.GetString(bytes); s = s.Replace("\r\n", "\n"); + s = s.Replace("\0", ""); var rows = s.Split('\n'); rows = rows.Skip(1).ToArray();