This project has moved. For the latest updates, please go here.

RichText Bugs?

Dec 15, 2010 at 3:08 PM

I've been running into some issues with RichText in  2.8 isn't an option for me based on the issue I submitted under issue tracker.

If I have a string in "Value" on a cell and then try to remvoe it and insert RichText I have to set "IsRichText=true" otherwise it shows the markup.  This happens even if I set "Value=nothing" first.

If I insert "abc" usign RichText into "C2" and then insert "hij" into "C3" I end up with "abchij" in "C3".  This also happens across columns and seems to be a running concantenation.  So if I insert into "A4", "B5", "C2", "D4" in that order "D4" will end up as a giant concantenation of them all, and the previous entries will be concantenations of the values that came before.  Calling RichText.Clear before I start working with each cell fixed the issue for me.

Dec 15, 2010 at 3:21 PM

OK, i'll have a look at that.

Dec 15, 2010 at 4:00 PM

I'll try and make an example for these as well.

Dec 15, 2010 at 5:17 PM
Edited Dec 15, 2010 at 5:18 PM

I tried making a simple example to show this... but I can't get it to happenin my simple examples on either version (2.7/2.8).  But sicne I found the work around it's not a big deal for me at the moment.

Different RichText issue that I can reproduce and have a sample for.  If I add rich text to a cell, then add another one and bold it, and finally add a third one everything from the bold one on get's bolded even though I didn't say too.  Is this by design or a bug?

Imports OfficeOpenXml
Imports System.IO

Module Module1
    Sub Main()
        Dim savepath As String = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".xlsx")

        Using xlPackage As New ExcelPackage()
            Dim xlWorkSheet = xlPackage.Workbook.Worksheets.Add("Test Sheet")

            For i As Integer = 1 To 10
                Dim cell2 As ExcelRange = xlWorkSheet.Cells(i, 1)
                cell2.RichText.Add("non bold ")
                cell2.RichText.Add(" bold text ").Bold = True
                cell2.RichText.Add(" shouldn't be bold but is ")

            xlPackage.SaveAs(New FileInfo(savepath))
        End Using

        Console.WriteLine("Saved to " + savepath)
    End Sub
End Module