mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
The spreadsheet engine parsed typed input with the invariant culture while displaying values with the current culture, breaking the edit round-trip on non-en-US hosts and making comma-decimal entry (10,50) impossible. Workbook gains a Culture property (defaults to CurrentCulture) which the component stamps from its inherited Culture parameter. It drives: - Cell input parsing (CellData type inference), including day-month date handling for cultures where the group and date separators collide (de-DE) - Edit text and display rendering (GetValue, GetValueAsString, GetDisplayText) - Number format rendering - format codes stay canonical invariant tokens while separators, month names, and AM/PM designators follow the culture - Formula entry and display via the new FormulaLocalizer (Excel FormulaLocal semantics: ';' argument separators and ',' decimals in comma-decimal cultures, lenient comma acceptance where unambiguous, canonical invariant storage) - Dialog input (data validation, conditional format, filter) via shared conversion helpers on SpreadsheetDialogBase XLSX and CSV files read and write canonical invariant values regardless of the workbook culture, including autofit column widths. Malformed formulas now surface as error trees instead of an unhandled lexer exception. Number format parsing is cached (hard-bounded) since CellView reparsed per render. Includes localization demos for the Spreadsheet and Document Processing sections and culture test suites. Note: headless code on non-en-US hosts now parses string values with the host culture; set Workbook.Culture explicitly (or to InvariantCulture) for host-independent processing.
52 lines
2.8 KiB
Plaintext
52 lines
2.8 KiB
Plaintext
@namespace Radzen.Blazor
|
|
@using Radzen.Blazor
|
|
@using Radzen.Blazor.Spreadsheet
|
|
@using Radzen.Blazor.Spreadsheet.Tools
|
|
@using Radzen.Documents.Spreadsheet
|
|
@inject DialogService DialogService
|
|
@inherits RadzenSpreadsheetToolBase
|
|
|
|
<RadzenSplitButton ButtonAriaLabel=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_ConditionalFormatTool))) OpenAriaLabel=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_ConditionalFormatTool))) title=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_ConditionalFormatTool))) Click=@OnClickAsync Icon="format_color_fill" Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_Conditional)) ?? "Conditional") Disabled=@IsDisabled Variant="Variant.Outlined" ButtonStyle="ButtonStyle.Base" Size="ButtonSize.Small">
|
|
<ChildContent>
|
|
<RadzenSplitButtonItem Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_GreaterThanMenu)) ?? "Greater Than...") Value="greater" />
|
|
<RadzenSplitButtonItem Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_LessThanMenu)) ?? "Less Than...") Value="less" />
|
|
<RadzenSplitButtonItem Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_BetweenMenu)) ?? "Between...") Value="between" />
|
|
<RadzenSplitButtonItem Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_EqualToMenu)) ?? "Equal To...") Value="equal" />
|
|
<RadzenSplitButtonItem Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_TextContainsMenu)) ?? "Text Contains...") Value="text" />
|
|
</ChildContent>
|
|
</RadzenSplitButton>
|
|
|
|
@code {
|
|
protected override SpreadsheetFeature? Feature => SpreadsheetFeature.ConditionalFormatting;
|
|
|
|
private async Task OnClickAsync(RadzenSplitButtonItem? item)
|
|
{
|
|
if (Worksheet is null || Worksheet.Selection.Cell == CellRef.Invalid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var ruleType = item?.Value switch
|
|
{
|
|
"less" => ConditionalFormatRuleType.LessThan,
|
|
"between" => ConditionalFormatRuleType.Between,
|
|
"equal" => ConditionalFormatRuleType.EqualTo,
|
|
"text" => ConditionalFormatRuleType.TextContains,
|
|
_ => ConditionalFormatRuleType.GreaterThan
|
|
};
|
|
|
|
var result = await DialogService.OpenAsync<ConditionalFormatDialog>(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_ConditionalFormattingTitle)) ?? "Conditional Formatting",
|
|
new Dictionary<string, object?>
|
|
{
|
|
{ "RuleType", ruleType },
|
|
{ "Culture", Worksheet.Culture }
|
|
});
|
|
|
|
if (result is ConditionalFormatBase rule && Spreadsheet is not null)
|
|
{
|
|
var command = new ConditionalFormatCommand(Worksheet, Worksheet.Selection.Range, rule);
|
|
await Spreadsheet.ExecuteAsync(command);
|
|
}
|
|
}
|
|
}
|