Use InvariantCulture instead of replacing ',' with '.'

This commit is contained in:
2024-01-06 14:23:17 +01:00
parent 3a89e16db3
commit d67e434fed
3 changed files with 8 additions and 5 deletions

View File

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
@ -264,7 +265,7 @@ namespace Elwig.Helpers.Export {
} else if (data is float || data is double || data is byte || data is char ||
data is short || data is ushort || data is int || data is uint || data is long || data is ulong) {
double v = double.Parse(data?.ToString() ?? "0");
double v = double.Parse(data?.ToString() ?? "0", CultureInfo.InvariantCulture);
if (units != null && units.Length > 0) {
int n = -1;
switch (units[0]) {
@ -274,7 +275,7 @@ namespace Elwig.Helpers.Export {
}
if (n >= 0) add = string.Join(" ", add.Split(" ").Select(p => p.StartsWith("table:style-name=") ? $"table:style-name=\"N{n}\"" : p));
}
c = $"<{ct} office:value-type=\"float\" calcext:value-type=\"float\" office:value=\"{v.ToString()?.Replace(",", ".")}\"{add}><text:p>{data}</text:p></{ct}>";
c = $"<{ct} office:value-type=\"float\" calcext:value-type=\"float\" office:value=\"{v.ToString(CultureInfo.InvariantCulture)}\"{add}><text:p>{data}</text:p></{ct}>";
} else {
c = $"<{ct} office:value-type=\"string\" calcext:value-type=\"string\"{add}><text:p>{data}</text:p></{ct}>";
}