Click here to Skip to main content
14,984,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I want to export html reports to word,excel and pdf document.
Posted
Comments
[no name] 13-Sep-14 7:11am
   
http://www.codeproject.com/Articles/24213/How-to-Use-Google-and-Other-Tips-for-Finding-Progr
Sid_Joshi 13-Sep-14 7:26am
   
ok thank u.

You can use iText, or its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^],
http://www.javatips.net/blog/2011/09/create-pdf-with-itext-java-tutorial[^].

I referenced Java documentation, because this is where the major documentation on iText is. If you understand C#, you will easily understand this Java documentation and apply it to iTextSharp C# or VB.NET code.

—SA
   
v2
VB
Dim fileName As String = Session("ClientGenCode") & "Leather_Pdf_" + DateTime.Now.ToShortDateString()
            Response.ContentType = "application/pdf"
            Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName + ".pdf"))
            Response.Cache.SetCacheability(HttpCacheability.NoCache)
            Dim html As String = ViewState("htmlText").ToString()
            Dim sb = New System.Text.StringBuilder()
            sb.Append(html)
            Dim objSW = New StringWriter(sb)
            Dim objTW = New HtmlTextWriter(objSW)
            Dim objSR As New StringReader(objSW.ToString())
            Dim objPDF = New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F)
            Dim objHW = New HTMLWorker(objPDF)
            PdfWriter.GetInstance(objPDF, Response.OutputStream)
            objPDF.Open()
            objHW.Parse(objSR)
            objPDF.Close()
            Response.Write(objPDF)
            Response.End()
   
Check this example of html to excel

html-to-excel-using-javascript-and-excel-to-html[^]
   
Comments
Sid_Joshi 13-Sep-14 7:24am
   
code creates excel document but, how to save it to disk?

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900