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.
Requirement:
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.
In addition, there are commercial DLLs out there (Telerik asp.net controls, Spreadsheet Gear, and others) that support spreadsheet like grids and export to Excel (and other formats) without Excel installed.
Member
284 Points
121 Posts
How to export C# datatable into Excel with HtmlFormatting
Nov 25, 2015 11:39 AM|raj.selvaa|LINK
I am using Asp.NET application with C#, in which having following data table
In this DataTable, HtmlContent column contains Html Tags, Image tags and File (PDF or Word or Video or Audio) in Link Format.
Requirement:
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.
Thanks,
Selvakumar S
Contributor
2770 Points
774 Posts
Re: How to export C# datatable into Excel with HtmlFormatting
Nov 25, 2015 12:07 PM|dhol.gaurav|LINK
Hi,
You have to write code manually to generate html.
Sample code available at below link
http://www.aspsnippets.com/Articles/Display-DataTable-in-HTML-Table-in-ASPNet-using-C-and-VBNet.aspx
http://www.c-sharpcorner.com/UploadFile/deveshomar/export-datatable-to-html-in-C-Sharp/
Gaurav Dhol
Skype ID : dhol.gaurav
Contributor
3462 Points
1341 Posts
Re: How to export C# datatable into Excel with HtmlFormatting
Nov 25, 2015 02:28 PM|Lannie|LINK
In addition, there are commercial DLLs out there (Telerik asp.net controls, Spreadsheet Gear, and others) that support spreadsheet like grids and export to Excel (and other formats) without Excel installed.