dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online Membersurpalshu
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

Html table to excel and take print


Posted Date: 15 Jun 2012      Posted By:: Saravana Perumal     Member Level: Silver    Member Rank: 530     Points: 2   Responses: 2



Hi to all..


I have a HTML Table with some data... now i want to export the data to excel and acess the excel file automatically and take the print.
How can i do this










Thanks & Regards
--------------------
Saravana Perumal.N




Responses

#675659    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 15/Jun/2012   Rating: 2 out of 52 out of 5     Points: 4

Here is a sample code to export the HTML data to EXCEL sheet


Response.ContentType = "application/force-download";
Response.AddHeader("content-disposition", "attachment; filename=Print.xls");

Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");

Response.Write("<head>");
Response.Write("<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");

Response.Write("<!--[if gte mso 9]><xml>");
Response.Write("<x:ExcelWorkbook>");
Response.Write("<x:ExcelWorksheets>");
Response.Write("<x:ExcelWorksheet>");
Response.Write("<x:Name>Report Data</x:Name>");
Response.Write("<x:WorksheetOptions>");
Response.Write("<x:Print>");
Response.Write("<x:ValidPrinterInfo/>");
Response.Write("</x:Print>");
Response.Write("</x:WorksheetOptions>");
Response.Write("</x:ExcelWorksheet>");
Response.Write("</x:ExcelWorksheets>");
Response.Write("</x:ExcelWorkbook>");
Response.Write("</xml>");
Response.Write("<![endif]--> ");
form1.innerHTML = output; // give ur html string here
Response.Write("</head>");
Response.flush();


Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM



 
#675676    Author: Asheej T K        Member Level: Diamond      Member Rank: 2     Date: 15/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi,
You will find a nice code in below thread. I would suggest you to use Gridview in place of HTML table for easy processing. Exporting to excel from HTML table is a tedious process and require lot of coding.

forums.asp.net/t/1214938.aspx


Regards,
Asheej T K
Microsoft MVP[ASP.NET/IIS]
DotNetSpider MVM

Dotnet Galaxy



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Binding Adrotator From Database
Previous : How to write c# code in Source code of page
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.