I am using a Rich text component from which I take input and store the generated HTML string in Database. While generating Excel, I along with this HTML string perform a few other operations (this does not change the HTML string). However, when I view the HTML string in Excel, it simply removes all the formatting and displays just the plain text.
I tried the following code:
Microsoft.Office.Interop.Excel.Range range = oSheet.get_Range(CellFrom, CellTo);
htmlString = htmlString.Replace("<br/>", "\r\n").Replace("</br>", "\r\n").Replace("<br>", "\r\n").Replace("</p>", "\r\n").Replace("<p>", "");
range.FormulaR1C1 = Regex.Replace(htmlString, "<.*?>", String.Empty);
range.Rows.AutoFit();
I also tried copying the HTML string to the clipboard and then paste it to Excel but that started showing popups to allow.
Is there a workaround for this ?