Beispiel #1
0
        private void ConvertToHtml(string inputFile, string outputFile)
        {
            using (var textWriter = new StreamWriter(outputFile))
            {
                this.WriteHtmlHeader(textWriter, Path.GetFileNameWithoutExtension(inputFile));

                using (var csvReader = new CsvReader(inputFile, new CsvOptions { HasHeader = true, Seperator = ';' }))
                {
                    textWriter.WriteLine("\t\t<table>");

                    if (csvReader.Options.HasHeader)
                    {
                        this.WriteTableHeader(textWriter, csvReader.Header);
                    }

                    this.WriteTableBody(textWriter, csvReader);

                    textWriter.WriteLine("\t\t</table>");
                }

                this.WriteHtmlFooter(textWriter);
            }
        }
Beispiel #2
0
        private void WriteTableBody(StreamWriter textWriter, CsvReader csvReader)
        {
            textWriter.WriteLine("\t\t\t<tbody>");

            var record = csvReader.ReadRecord();

            while (record != null)
            {
                this.WriteTableRow(textWriter, record, "td");

                record = csvReader.ReadRecord();
            }

            textWriter.WriteLine("\t\t\t</tbody>");
        }