@using System.Globalization
@using Radzen.Documents.Spreadsheet
Each row below is a Workbook with a different Culture. The canonical
Cell.Formula stays identical in every culture - only user-facing entry and display change.
Workbook.Culture defaults to CultureInfo.CurrentCulture; set it explicitly in
server-side code so results do not depend on the host locale.
@code {
class CultureRow
{
public string Culture { get; set; } = string.Empty;
public string LocalFormula { get; set; } = string.Empty;
public string CanonicalFormula { get; set; } = string.Empty;
public string FormattedNumber { get; set; } = string.Empty;
public string ParsedInput { get; set; } = string.Empty;
}
readonly List rows = [];
protected override void OnInitialized()
{
foreach (var name in new[] { "en-US", "de-DE", "es-ES", "fr-FR", "it-IT", "ja-JP" })
{
var workbook = new Workbook { Culture = CultureInfo.GetCultureInfo(name) };
var sheet = workbook.AddSheet("Sheet1", 5, 5);
sheet.Cells["A1"].Value = 1000;
sheet.Cells["A2"].Value = 234.5;
var formulaCell = sheet.Cells["B1"];
formulaCell.Formula = "=SUM(A1,A2)*1.5";
var formattedCell = sheet.Cells["C1"];
formattedCell.Value = 1234.5;
formattedCell.Format.NumberFormat = "#,##0.00";
var inputCell = sheet.Cells["D1"];
inputCell.SetValue("10,50");
rows.Add(new CultureRow
{
Culture = name,
LocalFormula = formulaCell.GetValue(),
CanonicalFormula = formulaCell.Formula,
FormattedNumber = formattedCell.GetDisplayText(),
ParsedInput = $"{Convert.ToString(inputCell.Value, CultureInfo.InvariantCulture)} ({inputCell.ValueType})"
});
}
}
}