Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > generating word document with header and footerwithout using word object.

Thread Tools

generating word document with header and footerwithout using word object.

Posts: n/a
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 " +
comfficeffice' " +
comffice:word'" +
REC-html40'>" +

sbTop.Append(@"<!--[if gte mso 9]>" +
"<xml>" +
microsoft-comffice:word'>" +
"<w:WordDocument>" +
wPr><w:r><w:t>My Header</w:t></w:r></w></w:hdr><w:sectPr>" +
"<w:View>Print</w:View>" +
"<w:Zoom>90</w:Zoom>" +
"</w:WordDocument>" +
"</xml>" +
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;"

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;}" +
"-->" +

sbTop.Append(@"<body lang=EN-US

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");
disposition", "attachment;
string strBody1=sbTop.ToString() +
strBody + bottom;

but it is not displaying footer but displaying the tables.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating Microsoft word document using ruby or rails. Prabu Jayaraman Ruby 1 02-20-2009 10:51 AM
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
generating word document with header and footerwithout using word object. srk ASP .Net 0 04-24-2007 01:59 PM
Auto-generating C header file from C++ header? Bit byte C++ 1 04-19-2006 01:40 AM
Generating Word document using Microsoft Office Html and XML Reference Vimal ASP .Net 0 10-14-2004 01:34 PM