kdunnett
asked on
Creating Word document with HttpContext but need page breaks
Good day all,
I have some code where I create a word document from some data on a page. This is working great. But I need to know how to call a page break for Word in HTML.
I'm calling the page in c# codebehind with asp.net off a click event of a button:
HttpContext.Current.Respon se.Clear() ;
HttpContext.Current.Respon se.Charset ="";
HttpContext.Current.Respon se.Content Type ="application/msword";
string strFileName = "GenerateDocument"+ ".doc";
HttpContext.Current.Respon se.AddHead er("Conten t-Disposit ion", "attachment;filename=" + strFileName);
strHTMLContent.Append("<br >".ToStrin g());
strHTMLContent.Append("<ta ble align='Center'>".ToString( ));
...
Any ideas?
Kris
I have some code where I create a word document from some data on a page. This is working great. But I need to know how to call a page break for Word in HTML.
I'm calling the page in c# codebehind with asp.net off a click event of a button:
HttpContext.Current.Respon
HttpContext.Current.Respon
HttpContext.Current.Respon
string strFileName = "GenerateDocument"+ ".doc";
HttpContext.Current.Respon
strHTMLContent.Append("<br
strHTMLContent.Append("<ta
...
Any ideas?
Kris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
dfu23:
i can get page breaks on the html, but that doen't transfer to Word when I open the document
rea_andrew:
no luck with that
i can get page breaks on the html, but that doen't transfer to Word when I open the document
rea_andrew:
no luck with that
try
strHTMLContent.Append("<br > ".T oString()) ;
or
strHTMLContent.Append("\r\ n\r\n".ToS tring());
--Nauman.
strHTMLContent.Append("<br
or
strHTMLContent.Append("\r\
--Nauman.
ASKER
All,
I played around with what dfu23's comment, and I got it:
strHTMLContent.Append("<br clear=all style='page-break-before:a lways'>".T oString()) ;
Only catch is that it has to be outside of the <table> tags and had to be part of a tag itself (like a <br> or <table>). That was my mistake, as I was trying to put each <tr> on a separate page and it wasn't working. Just did a complete table per page and volia.
All points to dfu23 as it got me here!
Kris
I played around with what dfu23's comment, and I got it:
strHTMLContent.Append("<br
Only catch is that it has to be outside of the <table> tags and had to be part of a tag itself (like a <br> or <table>). That was my mistake, as I was trying to put each <tr> on a separate page and it wasn't working. Just did a complete table per page and volia.
All points to dfu23 as it got me here!
Kris
Environment.NewLine?