Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 2nd, 2006, 05:38 AM
Authorized User
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
Default export to word

hey i m creating a report, i want to export it to word.
as the data is coming from various schema's and data is dynamic so after one page is over it should have header and footer with pagebreak.
right now i m using a word object in vb.net but it is not allowing me to create a new application due to some access problem even though i have given full rights to everyone.

pl help i have to release my system....

thnks in advance

Komila Kalia
Software Developer
Reliance engineering Associates (P) Ltd.
Old August 7th, 2006, 12:24 AM
Registered User
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Komila,
I am exporting to pfd.this code will help u exporting to word
on buttton click i am exporting my data to pdf.

u just hv to change this things:-
Response.ContentType = "application/vnd.ms-word";
ExportToStream(CrystalDecisions.Shared.ExportForma tType.WordForWindows)

private void export_Click(object sender, System.EventArgs e)

            // this is to give the log on info ...
            TableLogOnInfo logonInfo = new TableLogOnInfo();
            logonInfo = rpt.Database.Tables[0].LogOnInfo;
            logonInfo.ConnectionInfo.ServerName = "server";
            logonInfo.ConnectionInfo.DatabaseName = "shirazee";
            logonInfo.ConnectionInfo.UserID = "sa";
            logonInfo.ConnectionInfo.Password = "1234";
            MemoryStream oStream; // using System.IO

            // this code is to export report to pfd
                oStream = (MemoryStream)

                rpt.ExportToStream(CrystalDecisions.Shared.ExportF ormatType.PortableDocFormat);
                Response.Buffer= true;
                Response.ContentType = "application/pdf";

Old August 12th, 2006, 12:10 AM
Authorized User
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts

thnks for reply skajani
can u tell me if i want to convert to pdf then wat i have to write. and my report is not crystal report. its just an aspx page.

n even i want to add header and footer to my that report after and before page break.
do u have any idea how to do that.?:(
Old July 19th, 2013, 04:39 AM
Registered User
Join Date: Nov 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Komila, you can also try this .NET Word component. Here is a simple hello world sample code how to create and write word file in C# which will contain Hello World text, Page Break and a page number in footer:

// Create a new empty document.
DocumentModel document = new DocumentModel();

// Add document content.
    new Section(document,
        new Paragraph(document,
            new Run(document, "Hello World"),
            new SpecialCharacter(document, SpecialCharacterType.PageBreak))));

// Add document footer with page number.
    new HeaderFooter(document, HeaderFooterType.FooterDefault,
        new Paragraph(document,
            new Run(document, "Page number: "),
            new Field(document, FieldType.Page))));

// Save the document to a file.
To add you can easily convert Word file to a PDF in C# just by saving the document with .pdf extension.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to word document lily611 General .NET 2 July 30th, 2013 04:44 AM
Export a Table into Word hewstone999 Access VBA 0 March 20th, 2008 06:28 AM
problem with export to word an image ultra08rrg Pro JSP 1 December 20th, 2006 03:41 AM
Export Recordset to Word Document blackdevil1979 VB How-To 0 September 2nd, 2004 03:54 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.