Click here to Skip to main content
15,908,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

I have a WPF datagrid. Also I have a method for copying the grid values.


I have prepared the grid values as HTML format before pasting into excel. It is working fine. But after pasting into excel the tag based content getting removed.

What I have tried:

Example :

The Format is,

HTML
<pre><TABLE>
<TBODY>
<TR>
<TD>ID</TD>
<TD>Text_Usage</TD>
<TD>TagName</TD>
<TD>Match_Condition</TD>
<TD>TagValue</TD>
<TD>UseText</TD>
</TR>
<TR>
<TD>1877</TD>
<TD>RC_Rules</TD>
<TD><User_notes></TD>
<TD>Contains</TD>
<TD>6239</TD>
<TD>59920</TD>
</TR>
</TBODY></TABLE>


But after pasting into excel, The below value has removed.

HTML
<pre><TD><User_notes></TD>


Actually here the <user_notes> is a column value. But html consider it as Tag. I think that's the reason it got removed after pasting into excel.

How could I resolve this problem?
Posted
Updated 29-Apr-20 3:07am
Comments
Peter_in_2780 28-Apr-20 1:48am    
You could try replacing "<" and ">" around User_notes with "&lt;" and "&gt;". I don't know what escaping/unescaping is done where; you may need to experiment further.
Maciej Los 28-Apr-20 9:31am    
How does your method look like?
We can't read coffee grounds...

1 solution

You need to HTML-encode the values before inserting them into your HTML table.

For a WPF application, use the System.Net.WebUtility.HtmlEncode method:
WebUtility.HtmlEncode Method (System.Net) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900