Csv save
How to replace csv table contents from html table contents
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Megan Foster18 reputationPosted Feb 5, 2015, 12:10 AM EST
But here is how you can get a HTML table from CSV:
var htmlTable = new StringBuilder(); using (var csvFile = File.OpenText("Sample.csv")) { htmlTable.AppendLine(""); while (!csvFile.EndOfStream) { htmlTable.AppendLine(" "); foreach (var csvValue in csvFile.ReadLine().Split(',')) htmlTable.Append(" ").Append(csvValue).AppendLine(""); htmlTable.AppendLine(" "); } htmlTable.AppendLine(""); }var csvTable = new StringBuilder(); var doc = new HtmlDocument(); doc.Load(desktop + "\\Sample.html"); foreach (HtmlNode row in doc.DocumentNode.SelectSingleNode("table").Descendants("tr")) { foreach (var cell in row.ChildNodes) if (!string.IsNullOrWhiteSpace(cell.InnerText)) csvTable.Append(cell.InnerText).Append(','); csvTable.AppendLine(); }Also in case you are interested you can try out with this .NET library for excel files. It simplifies the process of converting spreadsheet content that comes from various formats into some other format. For example you can check out this article that shows how you can convert between CSV, HTML but also XLS and XLSX with C#.
Abc Thakur182 reputationPosted Feb 5, 2015, 12:56 AM EST
Megan Foster18 reputationPosted Feb 5, 2015, 9:56 PM EST
Unfortunately I haven't used PHP over 5 years now so...
But nevertheless try this for CSV to HTML:
http://stackoverflow.com/questions/518795/dynamically-display-a-csv-file-as-an-html-table-on-a-web-page#518923
And this for vice versa:
http://stackoverflow.com/questions/10498632/converting-html-table-to-a-csv-automatically-using-php#10498941