S
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='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.
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.