473,509 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2513

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

Similar topics

4
16140
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
4448
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
268
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
1899
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
2899
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
4608
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
1247
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
358
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
3405
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()...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.