Closed lpyedge closed 5 months ago
I believe the Excel error was created by Commit 578d768. [GridBlazor/ExcelWriter.cs] Line173 -174 I downgraded to version 4.1.1, and now the Excel export works well.
You are right. The issue about excel export is due to disposing the stream. I've published a new version (5.0.4) to fix it.
Referring the displayed language, I understand that the issue happens also in version 4.1.1, doesn't it? Are you using blazor-server or blazor-wasm?
You are right. The issue about excel export is due to disposing the stream. I've published a new version (5.0.4) to fix it.
Referring the displayed language, I understand that the issue happens also in version 4.1.1, doesn't it? Are you using blazor-server or blazor-wasm?
yes, the language displayed error is also happens in version 4.1.1 with blazor-server.
You can look at this sample project https://gridblazor.azurewebsites.net/. It is implemented as a blazor-server project.
The source code is here https://github.com/gustavnavar/Grid.Blazor/tree/master/GridBlazorServerSide.
There is a blazor component that configures the language for each session:
@using System.Globalization
@using Microsoft.AspNetCore.Builder
@using Microsoft.Extensions.Options
@inject NavigationManager NavigationManager
@inject IOptions<RequestLocalizationOptions> LocOptions
<select class="form-control" value="@_language" @onchange="SetLanguage">
@foreach (var culture in LocOptions.Value.SupportedUICultures)
{
<option value="@culture.Name">@culture.Name</option>
}
</select>
@code {
private string _language;
protected override void OnInitialized()
{
_language = CultureInfo.CurrentCulture.Name;
}
private void SetLanguage(ChangeEventArgs e)
{
var culture = (string)e.Value;
var uri = new Uri(NavigationManager.Uri)
.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
var query = $"?culture={Uri.EscapeDataString(culture)}&" +
$"redirectUri={Uri.EscapeDataString(uri)}";
NavigationManager.NavigateTo("/Culture/SetCulture" + query, forceLoad: true);
}
}
It calls to a web service that configures a cookie for the language:
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
namespace GridBlazorServerSide.Controllers
{
[Route("[controller]/[action]")]
public class CultureController : Controller
{
public IActionResult SetCulture(string culture, string redirectUri)
{
if (culture != null)
{
HttpContext.Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(
new RequestCulture(culture)));
}
return LocalRedirect(redirectUri);
}
}
}
The displayed language is based on the system language. The localization code scheme I use cannot display according to the language I set.