ClosedXML icon indicating copy to clipboard operation
ClosedXML copied to clipboard

Not possible to change "IXLRichString.Text" property

Open traf72 opened this issue 1 year ago • 0 comments

Do you want to request a feature or report a bug?

  • [x] Bug
  • [ ] Feature
  • [ ] Question

Did you test against the latest CI build?

  • [x] Yes
  • [ ] No

Version of ClosedXML

0.104.1

What is the current behavior?

Not possible to change the Text property of IXLRichString.

What is the expected behavior?

Possible to change the Text property of IXLRichString.

Is this a regression from the previous version?

  • [x] Yes. It worked in version 0.102.3.

Reproducibility

Code to reproduce problem:

public void Main()
{
    var wb = new XLWorkbook();
    var ws = wb.AddWorksheet();
    var cell = ws.Cell(1, 1);

    cell
        .CreateRichText()
        .AddText("Text 1")
        .SetItalic()
        .AddText(" Text 2")
        .SetBold();

    IXLRichString richString = cell.GetRichText().ToList().First();

    richString.Text = "Changed text"; // Assignment happens correctly and the "Text" property gets the new value

    Console.WriteLine(richString.Text); // Console shows "Changed text", so it was really changed

    IXLRichString richStringAfterChange = cell.GetRichText().ToList().First();
    Console.WriteLine(richStringAfterChange.Text); // Still has the initial value "Text 1"
}
  • [x] I attached a sample project.

ClosedXmlBug.zip

I suppose it's by design, but in my application I need to change the text of rich cells dynamically. How can I achieve this with the new version?

traf72 avatar Oct 04 '24 08:10 traf72