0.9.1
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user