EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

SetValue sets "" to cells containing multiple text colours

Open Michal-MK opened this issue 6 years ago • 2 comments

Calling SetValue on cells that have a text containing mutiple colours for example this. Are replaced by "" instead of the value provided to SetValue This simple script:

ExcelPackage p = new ExcelPackage(new FileInfo("sheet.xlsx"));
p.Workbook.Worksheets[1].SetValue("A1", "Text to replace");
p.Workbook.Worksheets[1].SetValue("A2", "B Color");
p.Save();

will set all of the text fields above to "" (by looking at the debugger)

Using: EPPlus 4.5.1.0

I can provide more info if necessary.

Michal-MK avatar Jun 01 '18 08:06 Michal-MK

I have the same issue in the 4.5.3.2 version. The cell value is always an empty string after modification. @EPPlus any thoughts?

VladimirRybalko avatar Oct 01 '19 14:10 VladimirRybalko

To avoid the issue you need to call the below method before setting any new value. p.Workbook.Worksheets[1].Cells[1,1].Clear()

Of course it will erase all text colors, however it works and not so critical for me.

VladimirRybalko avatar Oct 02 '19 07:10 VladimirRybalko