1

I have a stringbuilder object that contains html table. I want to write this string into a CSV file. Problem is that the CSV file shows the HTML tags as such. Is there a solution for this?

StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<html> <table style=\"border-collapse:collapse; text-align:center;\" >");
            sb.AppendFormat("<tr style =\"color:black;\">");
            sb.AppendFormat("<td style=\"border-color:black; border-style:solid; border-width:thin; \">" + "ColumnValue1" + " </td>");
            sb.AppendFormat("<td style=\"border-color:black; border-style:solid; border-width:thin; mso-number-format:'0' \">" + "ColumnValue2" + "</td>"); 
            sb.AppendFormat("</table></html>");

            File.WriteAllText("file.csv", sb.ToString());
user5663970
  • 119
  • 2
  • 13

0 Answers0