mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
Several catch-all (catch or catch (Exception)) blocks swallowed every exception type including critical ones like OutOfMemoryException and StackOverflowException, plus genuine bugs that should surface. Sites narrowed to specific exception types: - DataCellStore.FetchPageAsync: split into OperationCanceledException (rethrow) and other exceptions with logging. The previous silent swallow hid all data-load failures from the user. - FormulaFormat.IsRangeReference: ArgumentException / FormatException around RangeRef.Parse. - ChartDataResolver.ResolveCategories and ResolveValues: parse-related exceptions only (ArgumentException, FormatException, IndexOutOfRangeException, plus Conversion exceptions where ToDouble is involved). - RangePicker and RangePickerBar JS interop: JSDisconnectedException, JSException, ObjectDisposedException, TaskCanceledException only.
69 lines
1.5 KiB
C#
69 lines
1.5 KiB
C#
using System;
|
|
using Radzen.Documents.Spreadsheet;
|
|
|
|
namespace Radzen.Blazor.Spreadsheet;
|
|
|
|
#nullable enable
|
|
|
|
internal static class FormulaFormat
|
|
{
|
|
public static string ToAbsoluteFormula(Worksheet sheet, RangeRef range)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(sheet);
|
|
|
|
var start = new CellRef(range.Start.Row, range.Start.Column)
|
|
{
|
|
IsRowAbsolute = true,
|
|
IsColumnAbsolute = true,
|
|
};
|
|
var end = new CellRef(range.End.Row, range.End.Column)
|
|
{
|
|
IsRowAbsolute = true,
|
|
IsColumnAbsolute = true,
|
|
};
|
|
|
|
return $"{QuoteSheetName(sheet.Name)}!{start}:{end}";
|
|
}
|
|
|
|
public static bool TryParseFormula(string? text, out RangeRef range)
|
|
{
|
|
range = default;
|
|
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var trimmed = text.Trim();
|
|
|
|
if (trimmed.StartsWith('='))
|
|
{
|
|
trimmed = trimmed[1..].Trim();
|
|
}
|
|
|
|
try
|
|
{
|
|
range = RangeRef.Parse(trimmed);
|
|
return true;
|
|
}
|
|
catch (ArgumentException)
|
|
{
|
|
return false;
|
|
}
|
|
catch (FormatException)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static string QuoteSheetName(string name)
|
|
{
|
|
if (name.Contains(' ', StringComparison.Ordinal) || name.Contains('\'', StringComparison.Ordinal))
|
|
{
|
|
return $"'{name.Replace("'", "''", StringComparison.Ordinal)}'";
|
|
}
|
|
|
|
return name;
|
|
}
|
|
}
|