5
Answers

How to show excel data format in browser using c#?

Photo of Anish Kumar

Anish Kumar

8y
368
1
Advance Thanks...

Answers (5)

0
Photo of Farhan Shariff
NA 1.1k 111.5k 8y
Do u mean something like google doc viewer
This might help:
https://support.microsoft.com/en-us/kb/304662
http://stackoverflow.com/questions/5534534/view-excel-in-webbrowser-control-c-sharp
http://stackoverflow.com/questions/5114751/how-can-i-open-a-excel-inside-a-web-browser
0
Photo of Anish Kumar
NA 103 4.7k 8y
Bro, Its Fine... But my question is Showing the datatable values in excel format in one part of the browser ...
Not in table format.... Sorry this is urgent need!!
0
Photo of Farhan Shariff
NA 1.1k 111.5k 8y
  1. protectedstringExportDatatableToHtml(DataTabledt)
  2. {
  3. StringBuilderstrHTMLBuilder=newStringBuilder();
  4. strHTMLBuilder.Append("<html>");
  5. strHTMLBuilder.Append("<head>");
  6. strHTMLBuilder.Append("</head>");
  7. strHTMLBuilder.Append("<body>");
  8. strHTMLBuilder.Append("<tableborder='1px'cellpadding='1'cellspacing='1'bgcolor='lightyellow'style='font-family:Garamond;font-size:smaller'>");
  9. strHTMLBuilder.Append("<tr>");
  10. foreach(DataColumnmyColumnindt.Columns)
  11. {
  12. strHTMLBuilder.Append("<td>");
  13. strHTMLBuilder.Append(myColumn.ColumnName);
  14. strHTMLBuilder.Append("</td>");
  15. }
  16. strHTMLBuilder.Append("</tr>");
  17. foreach(DataRowmyRowindt.Rows)
  18. {
  19. strHTMLBuilder.Append("<tr>");
  20. foreach(DataColumnmyColumnindt.Columns)
  21. {
  22. strHTMLBuilder.Append("<td>");
  23. strHTMLBuilder.Append(myRow[myColumn.ColumnName].ToString());
  24. strHTMLBuilder.Append("</td>");
  25. }
  26. strHTMLBuilder.Append("</tr>");
  27. }
  28. //Closetags.
  29. strHTMLBuilder.Append("</table>");
  30. strHTMLBuilder.Append("</body>");
  31. strHTMLBuilder.Append("</html>");
  32. stringHtmltext=strHTMLBuilder.ToString();
  33. returnHtmltext;
  34. }
You can find the code and explaination from this article
http://www.c-sharpcorner.com/UploadFile/deveshomar/export-datatable-to-html-in-C-Sharp/
0
Photo of Anish Kumar
NA 103 4.7k 8y
Bro, By Data table , how to show the excel format in browser???
0
Photo of Farhan Shariff
NA 1.1k 111.5k 8y
You can import it to datatables and then display in a brower html