.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Santhakumar Munuswamy
Asad Ali
Fauzul Azmi
Post New Web Links

Code - Export To MSWord (Print Layout)

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net
 

Below is the code to use to Export the ASP.Net Page to MS-Word.
The below code has a feature that it exports in 'Print Layout' mode and not in Web-Layout.
For this feature to work you need to remove the <header> tag from ASPX.

string fileNameWord = "PrintView.doc";

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        BindPage(); // Your codt e to bind the page
        ExportToMSWord(fileNameWord);
    }
}

public void ExportToMSWord(string fileNameWord)
{
    string strBody = string.Empty;
    strBody = @"<html xmlns:o='urn:schemas-microsoft-com:office:office' " +
    "xmlns:w='urn:schemas-microsoft-com:office:word'" +
    "xmlns='http://www.w3.org/TR/REC-html40'>";

    strBody = strBody + "<!--[if gte mso 9]>" +
    "<xml>" +
    "<w:WordDocument>" +
    "<w:View>Print</w:View>" +
    "<w:Zoom>100</w:Zoom>" +


View Complete Post


More Related Resource Links

Key press in SSRS to Enable print/Email/Export

  
Hi All   How do we enable key press to the Print/ Export button in SSRS  Also how to enable Email in SSRS   Regards  Sooraj

SSRS Table Header working differently in and out of print layout

  
Please help. This is bizarre and seems like a bug to me. Using a table in SSRS, I have a details row, with a parent group and finally a header row.  For my header row, I am referencing a particular cell in the parent group. I am doing this so that i can have the header row repeat on each page of the group. This works fine when I'm not in Print Layout mode. However, when i switch to print layout mode, or print the report itself, the data that is presented on the screen is different then what is presented when not in print layout mode. WHAT THE F*!@!?? I've been battling this for a while now and i'm at my wits end. Has anyone else experienced different results from when you are in print layout mode as opposed to being in print layout mode?

Repeat header rows on all pages when you export to excel sheet and print it

  
Hello , I need to export report into excel sheet. And when people try to print it . The header rows only appear on First page of the print . Other subsequent pages d onot have header rows. I saw another thread saying SQL server 2008 R2 will solve the issue. Can you tell me that is fixed and how to i go about configuring it on SQL server 2008 R2.   Thanks Madhavi

Print Button +code in form

  
Using sharepoint 2010 and designed a simple form. How can I add the Print functionality to the ribbon from standard SP2010 NOT using Infopath? thx

PerformancePoint Dashboard using Excel Services - How to export or print?

  
I have a PPS dashboard in 2010 that has an Excel services report with a nice graph and grid.  I do not see an "export to Excel" toolbar or a print function.  In the old 2007 Sharepoint, the Excel services report had a menu which allowed the user to export to excel (copy / paste) or OPEN in Excel.  (actually open the pivot table) How do I expose that menu bar in 2010?  Thanks.

How to display print preview from code ?

  
Hi i'm working on a winform app which hosted of infopath form. is there any way to display print preview of infopath form from code ? in my form, i've used this code to show print preview of the current infopath form : this.formControl1.XmlForm.Print(true); but i got this exception : Specified cast is not valid. can anybody help me where is my problem and how to work-around this ? thanks in advance http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

Print option in InfoPath 2007 through Code

  
Hi All,

I am using the Info path 2007 web enabled. My requirements is to provide the Print option.

The Print option from standard tool bar i removed.

I need to print the current view form by using C# code.

I seached in net , i got help for Info Path 2003.I need help for Info path 2007 like PrintOut() in 2003.

Please help or suggest me to solve the requirements.


Crystal Report Export and Print button not working inside UpdatePanel

  

Hi

Iuse UpdatePanel for my pages, clients requested to view pages without flickering.

So, I put all component in update panel, but after that, export and printing for Crystal Reports stoped to work. If I put report viewer outside of updatepanel its working.

Have anyone this problem? There's some solution for this?

Thanks, Paul


Issues using code to export direct to PDF

  

This is for our invoiceing syste. What I am doing is running a SQL query to a SQLDatareader and then

 

    Private Sub CreatePDF(ByVal Licence As String, ByVal InvoiceNumber As String, ByVal EmailAddress As String)

        Dim FullFileName As String = "\\TESTSRV\TEMP\Invoice Number " & InvoiceNumber & ".PDF"

        ' Create Report DataSource
        Dim rds_INV_Header As New ReportDataSource("INV_Header", loadInvHeader_data(InvoiceNumber))
        ' Variables   
        Dim warnings As Warning()
        Dim streamIds As String()
        Dim mimeType As String = String.Empty
        Dim encoding As String = String.Empty
        Dim extension As String = String.Empty

        ' Setup the report viewer object and get the array of bytes   
        Dim viewer As New ReportViewer()
        AddHandler viewer.LocalReport.SubreportProcessing, AddressOf SetSubReportDataSource
        viewer.ProcessingMode = ProcessingMode.Local
        viewer.LocalReport.ReportPath = ".\Reports\Parent_Bureau_Invoice.rdlc"
        viewer.LocalReport.DataSources.Add(rds_INV_Header)
        ' Add datasource here
        Dim bytes As Byte() = viewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamIds, warnings)


        Using fs As New FileStream(FullFil

Help needed amending code for rdlc export to PDF

  

 VS2010 & SQL2010

I have a RDLC Report with various subreports. Using examples from this site I have managed the following code. What I am stumped on getting the pdf auto saved to a specified directory

can anyone help

 

   Private Sub CreatePDF(ByVal fileName As String, ByVal InvoiceNumber As String)

        InvNumber = InvoiceNumber
        ' Create Report DataSource
        Dim rds_INV_Header As New ReportDataSource("INV_Header", loadInvHeader_data(InvoiceNumber))
        ' Variables   
        Dim warnings As Warning()
        Dim streamIds As String()
        Dim mimeType As String = String.Empty
        Dim encoding As String = String.Empty
        Dim extension As String = String.Empty

        ' Setup the report viewer object and get the array of bytes   
        Dim viewer As New ReportViewer()
        viewer.ProcessingMode = ProcessingMode.Local
        viewer.LocalReport.ReportPath = ".\Reports\Parent_Bureau_Invoice.rdlc"
        viewer.LocalReport.DataSources.Add(rds_INV_Header)
        AddHandler viewer.LocalReport.SubreportProcessing, AddressOf SetSubReportDataSource
        ' Add datasource here
        Dim bytes As Byte() = viewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamIds, warnings)

        ' Now that you h

export datatable from .net code page (aspx.cs) to sql stored procedure

  

Hi experts

Can any body tell can we pass datatable from code page to sql stored procedure. If yes tell me how.

 

Any sugession acceptable.

Thankyou

Sushmitha


Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

  
When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Free Code Snippets - ASP.NET

  
You Can Find Useful ASP.NET Related Posts on the above link.

Free Code Snippets - C#

  
Free C# Code Snippets

Export Visio Database Table Names to Excel

  
If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend