How to export C# datatable into Excel with HtmlFormatting RRS feed

  • Question

  • User-745611520 posted

    I am using Asp.NET application with C#, in which having following data table

    DataTable dt = new DataTable();
    dt.Columns.Add("S.No", typeof(int));
    dt.Columns.Add("HtmlContent", typeof(int));
    dt.Rows.Add("1", "Hi, I am <b>XXX</b>");
    dt.Rows.Add("2", "<b>Great</b> <i>Work</i>");
    dt.Rows.Add("3","This is Sample Image <img src='smiley.gif' alt='Smiley face' height='42' width='42'>");
    dt.Rows.Add("4", "This is attached file <a href='../Content/FileManager/Documents/Product Review.docx'>../Content/FileManager/Documents/Product Review.docx</a>");

    In this DataTable, HtmlContent column contains Html Tags, Image tags and File (PDF or Word or Video or Audio) in Link Format.


    I want to export this data table into excel format, My Server does not contain MS-Office Excel, Content should be rendered as Html in Excel cell, If any of the image file is available then displayed within the excel cell, If any of the file (PDF or Word or Video or Audio) available then It should Embed that object into Excel cell.

    Kindly refer the attached Image to view my final output.

    I have searched online but could not get appropriate solution approach, Kindly provide some help.


    Selvakumar S


    Wednesday, November 25, 2015 11:39 AM

All replies