I use ClosedXML
to generate Excel file, taking data from Microsoft SQL Server. And I write the Date in this fotmat: DDDD D-MM-yyyy
.The problem is that it writes in English. I want to set Italian language as default.
This is how I generate Excel file:
foreach (Attivita attivita in listAttivita)
{
worksheet.Cell(index, 1).Value = attivita .Data;
worksheet.Cell(index, 1).Style.NumberFormat.Format = "DDDD D-MM-yyyy";
worksheet.Cell(index, 2).Value = attivita.Ord;
worksheet.Cell(index, 3).Value = attivita.Straord;
worksheet.Cell(index, 4).Value = attivita.Per;
worksheet.Cell(index, 5).Value = attivita.Fer;
worksheet.Cell(index, 6).Value = attivita.Mala;
worksheet.Cell(index, 7).Value = attivita.Infor;
worksheet.Cell(index, 8).Value = attivita.Cassa;
index++;
}
Allso I set CultureInfo
in Stratup.cs
but I'm not sure if I'm doing something wrong:
public void ConfigureServices(IServiceCollection services)
{
CultureInfo[] supportedCultures = new[]
{
new CultureInfo("it-IT")
//new CultureInfo("en")
};
services.Configure<RequestLocalizationOptions>(options =>
{
options.DefaultRequestCulture = new RequestCulture("it-IT");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
options.RequestCultureProviders = new List<IRequestCultureProvider>
{
new QueryStringRequestCultureProvider(),
new CookieRequestCultureProvider()
};
});
}
Anycase this doesn't worked for me when I published the project in IIS.
Update
dddd d-mm-yyyy = "Thursday 28-August-2014"
Update 2:
Value of attivita.Data
:
attivita.Data = {01/12/2020 00:00:00}
When I do this :
worksheet.Cell(index, 1).Value = attivita.Data.ToString("dddd, d-MMMM-yyyy", new CultureInfo("it-IT"));
And when I do this :
worksheet.Cell(index, 1).Value = attivita.Data.ToString("dddd, d-mmmm-yyyy", new CultureInfo("it-IT"));
It should be like this . The only problem are the 00 that put there. And I can't get why is not working with this dddd, d-MMMM-yyyy
that seems to be correct.
Any suggestions how to write the Date in italian, and set Italian as default language ?