locked
Convert DataTable to html table without DataGrid RRS feed

  • Question

  • Hi,

    Does anyone has a routine to convert a DataTable to html code ?

    I can't use datagrid, cause I will add more html to it...

    Thanks

    Wednesday, October 25, 2006 4:35 PM

Answers

  • I've done...

    I can't use it cause the code is everything generated by C#, and after that I'm gonna convert it to .DOC, and crystal could not do It cause I'm gonna use 3 tables. from a dataset.

    Wednesday, October 25, 2006 5:40 PM

All replies

  • Well, first of all, you need to "add more html to it" could probably be satified by using a DataGrid and capturing the ItemDataBound event.   Or you could use Template columns.

    Or use a DataList control or a Repeater control.

     

    Wednesday, October 25, 2006 4:50 PM
  • I've done...

    I can't use it cause the code is everything generated by C#, and after that I'm gonna convert it to .DOC, and crystal could not do It cause I'm gonna use 3 tables. from a dataset.

    Wednesday, October 25, 2006 5:40 PM
  • You can try this. The code is very simple to understand:

    http://simplyvisualbasic.blogspot.com/2011/05/convert-datatable-to-html-table.html

    Friday, September 9, 2011 5:06 PM
  • Hi, here is another solution which uses this C# Excel component, it has a really simple API for exporting DataTable to HTML or Excel file:

    var file = new ExcelFile();
    var sheet = file.Worksheets.Add("Imported Data");
    
    sheet.InsertDataTable(dataTable, 
        new InsertDataTableOptions("A1") { ColumnHeaders = true });
    
    // Save as HTML file.
    file.Save("DataTable.html", SaveOptions.HtmlDefault);

    Tuesday, July 9, 2013 10:47 AM