Hi,
1. I tested with your input file and was able to reproduce the issue
2. netcoreapp3.1
3. I can reproduce the issue on 2 different machines:
a. my local machine:
CurrentCulture = de-AT
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\
dotnet
b. Azure web app:
CurrentCulture = en-US
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x86
Base Path: D:\Program Files (x86)\dotnet\sdk\6.0.100\
4. Output type is "Console Application", my code runs as part of a asp.net web service controller (Microsoft.AspNetCore.Mvc.ControllerBase)
Additionally, I was able to determine that
all versions starting from 10.11.2 of Spire.XLS are causing the issue. Prior versions work as expected.
This is my code:
- Code: Select all
private byte[] SheetAsCSV(Worksheet worksheet, string cultureInfo)
{
using (MemoryStream outputStream = new MemoryStream())
{
// remember current culture
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
// set culture info if given, default to de-DE
if (!string.IsNullOrEmpty(cultureInfo))
Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureInfo);
else
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
// generate CSV, numbers are formatted based on culture info
worksheet.SaveToStream(outputStream, ";", Encoding.UTF8);
// set culture info back to default
Thread.CurrentThread.CurrentCulture = currentCulture;
return outputStream.ToArray();
}
}
The result is always formatted using the machine's preset culture, regardless of what I am setting CurrentCulture to.
KR,
Gerhard