generating word document with header and footerwithout using word object.

Discussion in 'ASP .Net' started by srk, Apr 24, 2007.

  1. srk

    srk Guest

    hi to all,
    i need some help , my problem is that i have to generate a
    word document withe the data from data base and it should be displayed
    as tables in word and i have to insert some header and footer in word
    along with the page number. i got the code for generating tables and
    it is fine now i am trying for header and footer but i am failing
    here. i am sending my code , just check it.


    StringBuilder sbTop = new StringBuilder();

    sbTop.Append(@"<html " +
    "xmlns:eek:='urn:schemas-microsoft-com:eek:ffice:eek:ffice' " +
    "xmlns:w='urn:schemas-microsoft-com:eek:ffice:word'" +
    "xmlns='http://www.w3.org/TR/REC-html40'>" +
    "<head><title></title>");

    sbTop.Append(@"<!--[if gte mso 9]>" +
    "<xml>" +
    //"<xmlns:w='urn:schemas-microsoft-com:eek:ffice:word'>" +
    "<w:WordDocument>" +
    //"<w:sectPr><w:hdr><w:p><w:pPr><w:pStyle w:val='Header'/></
    w:pPr><w:r><w:t>My Header</w:t></w:r></w:p></w:hdr><w:sectPr>" +
    "<w:View>Print</w:View>" +
    "<w:Zoom>90</w:Zoom>" +
    "</w:WordDocument>" +
    "</xml>" +
    "<![endif]-->");
    sbTop.Append("<style>" +
    "<!-- /* Style Definitions */" +
    "p.MsoFooter, li.MsoFooter,
    div.MsoFooter" +
    "{margin:0in;" +
    "margin-bottom:.0001pt;" +
    "mso-pagination:widow-orphan;" +
    "tab-stops:center 3.0in right 6.0in;"
    +
    "font-size:12.0pt;}");

    sbTop.Append("@page Section1" +
    " {size:8.5in 11.0in; " +
    " margin:1.0in 1.25in 1.0in 1.25in ; " +
    " mso-header-margin:.5in; " +
    " mso-footer: f1;" +
    " mso-footer-margin:.5in; mso-paper-source:0;}" +
    " div.Section1" +
    " {page:Section1;}" +
    "-->" +
    "</style></head>");

    sbTop.Append(@"<body lang=EN-US style='tab-interval:.5in'>");

    sbTop.Append("<div style='mso-element:footer' id=f1>" +
    " <p class=MsoFooter>" +
    " <span style='mso-tab-count:1'>my
    footer</span>" +//<span style='mso-field-code:'PAGE''></span>" +
    " </p></div>");



    and here i am taking data from data base and and displaying through
    html tables

    and using the content-type for throwing the word file to save.

    Response.AppendHeader("Content-Type", "application/msword");
    Response.AppendHeader("Content-disposition", "attachment;
    filename=some1234.doc");
    string strBody1=sbTop.ToString() + strBody + bottom;
    Response.Write(strBody1);







    but it is not displaying footer but displaying the tables.
     
    srk, Apr 24, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Tm92aWNl?=

    Generating Word document from information in Database

    =?Utf-8?B?Tm92aWNl?=, Jun 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    454
    =?Utf-8?B?Tm92aWNl?=
    Jun 9, 2004
  2. Vimal
    Replies:
    0
    Views:
    522
    Vimal
    Oct 14, 2004
  3. Bit byte
    Replies:
    1
    Views:
    681
    benben
    Apr 19, 2006
  4. srk
    Replies:
    0
    Views:
    646
  5. Prabu Jayaraman
    Replies:
    1
    Views:
    259
    Robert Klemme
    Feb 20, 2009
Loading...

Share This Page