Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi All,
 
I need to convert html page to excel with formatting using c#. Please help me to work on this. Or suggest me any third party tools to convert html to excel (with formatting).
 
Thanks in Advance,
Arunachalam M.
Posted 6-Jan-13 19:47pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

What formatting ? Excel will open a CSV, so just emit your data as a CSV to create an Excel compatible download.
  Permalink  
Comments
Arunachalam Muthukumar at 7-Jan-13 2:02am
   
For instance, the content in html table (td) is (15,345). When this is exported to excel, it will be changed to -15,345. Thats why I am looking for the tool to export to excel with formatting.
Christian Graus at 7-Jan-13 2:20am
   
So you put (15,345) in the column of your CSV
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

As for html to excel with formatting issue, you can see below code:
Response.Clear();
Response.Buffer = true;
Response.AppendHeader("Content-Disposition","attachment;filename="+DateTime.
Now.ToString("yyyyMMdd")+".xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = ""application/ms-excel";;
this.EnableViewState = false;
 
The "ContentType" property which the default set is text/HTML can help us a lot. And hypertext will be exported to client. If we change it to ms-excel, it will be exported as Excel format and your browser will remind you to download and store it. The property of "ContentType" includes image/JPEG, text/HTML, image/GIF and vnd.ms-excel/msword.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 735
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,198
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,470


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100