This commit is contained in:
melekhin
2026-06-08 14:31:31 +07:00
parent f9cca53f75
commit f5eb667973
36 changed files with 159 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
namespace QWERTYkez.ExcelProcessor.Editors;
namespace QWERTYkez.ExcelProcessor;
/// <summary>
/// Внутренняя реализация <see cref="ICell"/>.
@@ -390,7 +390,7 @@ internal sealed class ExcelCell : ICell
}
}
public ICell Set(Action<ICellText> value)
public ICell Text(Action<ICellText> value)
{
if (value == null) return this;
_writer.ThrowIfDisposed();
@@ -425,6 +425,39 @@ internal sealed class ExcelCell : ICell
return this;
}
/// <inheritdoc />
public ICellText? Text()
{
_writer.ThrowIfDisposed();
lock (_writer._syncLock)
{
var cell = GetCellElement();
if (cell == null || cell.DataType?.Value != CellValues.InlineString || cell.InlineString == null)
return null;
var textObj = new ExcelCellText();
foreach (var run in cell.InlineString.Elements<Run>())
{
string text = run.GetFirstChild<Text>()?.Text ?? string.Empty;
RunFormat? format = null;
if (run.RunProperties != null)
{
// Преобразуем RunProperties в RunFormat (можно вынести в отдельный метод)
format = RunFormat.FromRunProperties(run.RunProperties);
}
textObj.AddRun(text, format);
}
return textObj;
}
}
/// <inheritdoc />
public bool TryText(out ICellText cellText)
{
cellText = Text()!;
return cellText is not null;
}
public ICell Set(string value)
{
if (value == null) return this;