Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

generating word document with header and footerwithout using word object.

 
 
srk
Guest
Posts: n/a
 
      04-25-2007
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='urn:schemas-microsoft-
comfficeffice' " +
"xmlns:w='urn:schemas-microsoft-
comffice:word'" +
"xmlns='http://www.w3.org/TR/
REC-html40'>" +
"<head><title></title>");

sbTop.Append(@"<!--[if gte mso 9]>" +
"<xml>" +
//"<xmlns:w='urn:schemas-
microsoft-comffice:word'>" +
"<w:WordDocument>" +
//"<w:sectPr><w:hdr><w><wPr><wStyle
w:val='Header'/></
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>" +
"<![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.

 
Reply With Quote
 
 
 
Reply

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



Advertisments