Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Commented Issue: ExcelRichText.PreserveSpace still removes leading and trailing white-space characters [14801]

$
0
0
Using cell's RichText collection to display mixed style formatting in one cell is great!
The issue is that the PreserveSpace feature (which should be true by default) is not working.

Here I'd like to display the equivalent of HTML's "<b>toto:</b>&amp;nbsp;tata", using the following code:
```
cell.RichText.Add("toto: ");
cell.RichText[0].PreserveSpace = true;
cell.RichText[0].Bold = true;
cell.RichText.Add("tata");
```
The result however is not as expected; there is no space between "toto:" and "tata", which in excel XML looks like:
```
<Cell>
<ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40"><B>toto:</B><Font
html:Color="#000000">tata</Font></ss:Data>
</Cell>
```
instead of:
```
<Cell>
<ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40"><B>toto: </B><Font
html:Color="#000000">tata</Font></ss:Data>
</Cell>
```

I noticed that each time I manually set my RichText[0].PreserveSpace = true, it then reset its value to false, as one can see in the PreserveSpace property of the [Source Code](http://epplus.codeplex.com/SourceControl/changeset/view/6852709011e3#EPPlus/Style/ExcelRichText.cs).
I don't know if this has an impact on the rest, but the code elem.SetAttribute("xml:space", "preserve"); seems not to prevent removing leading and trailing white-space characters from my RichText value.

Could you please fix this?

Thanks!
Comments: I had a similar problem but found that changing: Loop start output_sheet.Cells[row_index, col_index].RichText.Add("text"); Loop end To var rt = output_sheet.Cells[row_index, col_index].RichText; Loop start rt.Add("text"); Loop end Solved my issue. It appears accessing the RichText property for the cell each time sets the existing values to false for preservespace, regardless of what they were originally.

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>