473,378 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

generating word document with header and footerwithout using word object.

srk
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:o='urn:schemas-microsoft-com:office:office' " +
"xmlns:w='urn:schemas-microsoft-com:office: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:office: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.

Apr 24 '07 #1
0 2498

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Microsoft | last post by:
I'm trying to display a word document inside a web page, but everytime I do I get this error: Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied: 'CreateObject' Does...
1
by: Vijay | last post by:
Hi, I have to generate a word or rtf file on the fly whould have a Header and footer both but i m not able to include the header and footer in the document can anyone suggest me how can i do...
0
by: Novice | last post by:
Hi all, I'm a novice VB.NET and VBA programmer and am wondering if there is a tutorial out there on how to create a word document based on data in a database and then return that document to a web...
10
by: Noor | last post by:
Hi all, I need to well formatted ms word document through vb.net. All the data that will make the word document will come from the database. and formatted dynamically. Currently i have...
1
by: bluestar | last post by:
hello i am trying to develope an application for word automation.i need to insert header and footer to the document. i found an exampke in msdn and used it in my application.it works well;but...
6
by: Eric Layman | last post by:
Hi, I have fields from textareas. With a click of a button, php is able to grab these fields and by using header(), convert the output to Ms Word doc. But the outcome of the word doc...
13
by: yasodhai | last post by:
Hi, I developed a web application which contains a text box and a command button. Once if i enter some text and then if i click the command button, the contents in the textbox should be displayed...
0
by: srk | last post by:
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...
6
by: BlackMustard | last post by:
hi, i'm using the following code to modify a standard word document and save it to disk with a new file name. Sub CreateQuote()...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.