423,309 Members | 2,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,309 IT Pros & Developers. It's quick & easy.

Creating Word documents on page

P: n/a
I have found some code that shows how to convert an html
form to Word. The message said to simply put the following
in the Page_load:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Now all I should have to do is create the page just like I
would if I were going to display it in the browser.

I create the document in the browser using code similar to
the following:
Response.Write("<table width=""100%"">")
Response.Write(" <tr height=1><td align=right><img
src=""images\bp_white2_icon.ico""></tr>")
Response.Write(" <tr><td align=center><font size=+3>My
Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP
Cases Status Report</font></tr>")

'==============================================
'MAIN TABLE
'==============================================
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%""
cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House
Counsel<td># of Pltfs<td>Status<td>BP Billing
Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'==============================================
'MAIN TABLE
'==============================================
Response.Write("</table>")
The page loads fine until I try to load it as a Word
document. I know that someone out there has done this.

Can anyone help?

Thanks
enak


Nov 17 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
What do you mean by "get fine until....". What eroor do
you get ?

and why do you use Response.Write ? Are you doing ASP.NET
or ASP ?
-----Original Message-----
I have found some code that shows how to convert an html
form to Word. The message said to simply put the followingin the Page_load:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Now all I should have to do is create the page just like Iwould if I were going to display it in the browser.

I create the document in the browser using code similar tothe following:
Response.Write("<table width=""100%"">")
Response.Write(" <tr height=1><td align=right><img
src=""images\bp_white2_icon.ico""></tr>")
Response.Write(" <tr><td align=center><font size=+3>My
Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP
Cases Status Report</font></tr>")

'==============================================
'MAIN TABLE
'==============================================
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%""
cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House
Counsel<td># of Pltfs<td>Status<td>BP Billing
Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'==============================================
'MAIN TABLE
'==============================================
Response.Write("</table>")
The page loads fine until I try to load it as a Word
document. I know that someone out there has done this.

Can anyone help?

Thanks
enak


.

Nov 17 '05 #2

P: n/a
Thanks for your response.

I am using asp.net. If I try to display the page with just
the HTML the page displays as I would expect.

However, if I add the following two lines the page is
blank:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Currently, I am using HTML but should I be doing it
differently? Can I use a datagrid rather than <table>?

Thanks,
enak
-----Original Message-----
What do you mean by "get fine until....". What eroor do
you get ?

and why do you use Response.Write ? Are you doing ASP.NET
or ASP ?
-----Original Message-----
I have found some code that shows how to convert an html
form to Word. The message said to simply put the

following
in the Page_load:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Now all I should have to do is create the page just like

I
would if I were going to display it in the browser.

I create the document in the browser using code similar

to
the following:
Response.Write("<table width=""100%"">")
Response.Write(" <tr height=1><td align=right><img
src=""images\bp_white2_icon.ico""></tr>")
Response.Write(" <tr><td align=center><font size=+3>My
Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP
Cases Status Report</font></tr>")

'============================================= =
'MAIN TABLE
'============================================= =
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%""
cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House
Counsel<td># of Pltfs<td>Status<td>BP Billing
Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'============================================= =
'MAIN TABLE
'============================================= =
Response.Write("</table>")
The page loads fine until I try to load it as a Word
document. I know that someone out there has done this.

Can anyone help?

Thanks
enak


.

.

Nov 17 '05 #3

P: n/a
I just tried your code and it works (not if you do this in
a page load. Only at a postback from an button_click event
for example).

This can work only if you have at least office 2000 and IE
5.5.
-----Original Message-----
Thanks for your response.

I am using asp.net. If I try to display the page with justthe HTML the page displays as I would expect.

However, if I add the following two lines the page is
blank:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Currently, I am using HTML but should I be doing it
differently? Can I use a datagrid rather than <table>?

Thanks,
enak
-----Original Message-----
What do you mean by "get fine until....". What eroor do
you get ?

and why do you use Response.Write ? Are you doing ASP.NETor ASP ?
-----Original Message-----
I have found some code that shows how to convert an htmlform to Word. The message said to simply put the

following
in the Page_load:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Now all I should have to do is create the page just
likeI
would if I were going to display it in the browser.

I create the document in the browser using code similar

to
the following:
Response.Write("<table width=""100%"">")
Response.Write(" <tr height=1><td align=right><img
src=""images\bp_white2_icon.ico""></tr>")
Response.Write(" <tr><td align=center><font size=+3>My
Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP
Cases Status Report</font></tr>")

'============================================ ==
'MAIN TABLE
'============================================ ==
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%""
cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House
Counsel<td># of Pltfs<td>Status<td>BP Billing
Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'============================================ ==
'MAIN TABLE
'============================================ ==
Response.Write("</table>")
The page loads fine until I try to load it as a Word
document. I know that someone out there has done this.

Can anyone help?

Thanks
enak


.

.

.

Nov 17 '05 #4

P: n/a
I need this to work from the Page_Load. What I do is on
the Page_Load I call a sub that creates the page in HTML.
I have the two lines for the Word object in the Page_Load.

Do you know how I can make this work?

I have ie 5.5 and office 2000
-----Original Message-----
I just tried your code and it works (not if you do this ina page load. Only at a postback from an button_click eventfor example).

This can work only if you have at least office 2000 and IE5.5.
-----Original Message-----
Thanks for your response.

I am using asp.net. If I try to display the page with

just
the HTML the page displays as I would expect.

However, if I add the following two lines the page is
blank:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Currently, I am using HTML but should I be doing it
differently? Can I use a datagrid rather than <table>?

Thanks,
enak
-----Original Message-----
What do you mean by "get fine until....". What eroor do
you get ?

and why do you use Response.Write ? Are you doingASP.NETor ASP ?

-----Original Message-----
I have found some code that shows how to convert anhtmlform to Word. The message said to simply put the
following
in the Page_load:

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

Now all I should have to do is create the page justlikeI
would if I were going to display it in the browser.

I create the document in the browser using code similarto
the following:
Response.Write("<table width=""100%"">")
Response.Write(" <tr height=1><td align=right><img
src=""images\bp_white2_icon.ico""></tr>")
Response.Write(" <tr><td align=center><font size=+3>My
Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP
Cases Status Report</font></tr>")

'============================================= =
'MAIN TABLE
'============================================= =
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%""
cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House
Counsel<td># of Pltfs<td>Status<td>BP Billing
Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'============================================= =
'MAIN TABLE
'============================================= =
Response.Write("</table>")
The page loads fine until I try to load it as a Word
document. I know that someone out there has done this.

Can anyone help?

Thanks
enak


.

.

.

.

Nov 17 '05 #5

P: n/a
Hi Enak,

Thank you for posting to the MSDN Managed newsgroups. We are acknowledging
your post and you should receive response from the community within 2
business days of your post.

If you have any concerns, please feel free to let us know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #6

P: n/a
Hi Enak,

I am sorry if there is any misunderstanding.

As I understand, what you want is exporting data to MS word. I have found
some articles regarding how to Export data to Excel. I hope it helps.

Export to Excel
http://www.aspnetpro.com/NewsletterA..._l/asp200309so
_l.asp
"...
Use ASP.NET to send functionally rich reports to your users.
..."

HOW TO: Export Data in a DataGrid on an ASP . NET WebForm to Microsoft Excel
http://support.microsoft.com/default...b;en-us;317719

In addition, please upgrade to IE6 and test this issue again.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #7

P: n/a
Jacob, thanks for doing the research.

My original post talked about something a little different.

I can create the page using HTML and tables. It displays
just fine but then I read on ASP.Net forum that once I
have done that all I need to do is add the following to
the Page_Load function and the HTML will be converted to
Word.

Response.ContentType = "application/vnd.ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

This brings up a page that does not look anything like
mine. Do you have any experience with this?

Thanks
enak
-----Original Message-----
Hi Enak,

I am sorry if there is any misunderstanding.

As I understand, what you want is exporting data to MS word. I have found some articles regarding how to Export data to Excel. I hope it helps.
Export to Excel
http://www.aspnetpro.com/NewsletterA...003/09/asp2003 09so_l/asp200309so_l.asp
"...
Use ASP.NET to send functionally rich reports to your users...."

HOW TO: Export Data in a DataGrid on an ASP . NET WebForm to Microsoft Excelhttp://support.microsoft.com/default.aspx?scid=kb;en- us;317719
In addition, please upgrade to IE6 and test this issue again.
If I have misunderstood your concern, please feel free to let me know.
Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #8

P: n/a
Hi Enak,

Thank you for your update.

I have already tested your code on my side. Please try the following steps
on your side. (I am using Windows XP Pro/VS.NET 2003/IE 6)

1. Create a default web application.

2. Add the following code in Page_Load.

Response.Write("<table width=""100%"">")
Response.Write(" <tr><td align=center><font size=+3>My
Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP Cases Status
Report</font></tr>")

'==============================================
'MAIN TABLE
'==============================================
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%"" cellspacing=3
cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of
Pltfs<td>Status<td>BP Billing Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'==============================================
'MAIN TABLE
'==============================================
Response.Write("</table>")

3. Build and Run the application.

4. We can see the table we creat.

5. Right click the page and select "View Source". We can see the following
HTML code.
----------------------------------------------
<table width="100%"> <tr><td align=center><font size=+3>My
Report</font></tr> <tr><td align=center><font size=+3>BP Cases Status
Report</font></tr> <tr><td> <table border=0 width="100%" cellspacing=3
cellpadding=0> <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of
Pltfs<td>Status<td>BP Billing Breakdown</tr> </table> </tr></table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9o veFlT" />

<FONT face="Arial"></FONT>
</form>
</body>
</HTML>
----------------------------------------------

6. Then please add the following two statements in Page_Load.

Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

7. Build and run the application again. After click the "Open" button, we
can find that only the content between "<HTML>" and "</HTML>" are converted
to word. That is the reason of this issue.

8. Then please change the code in Page_Load as the following:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")
End Sub

9. Change the HTML code of the web form as the following:
--------------------------------------------------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="TestWord.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="Arial"></FONT>
</form>
<table width="100%">
<tr>
<td align="center"><font size="+3">My Report</font></td>
<tr>
<td align="center"><font size="+3">BP Cases Status Report</font></td>
<tr>
<td>
<table border="0" width="100%" cellspacing="3" cellpadding="0">
<tr bgcolor="#bbbbbb">
<td>
Lead Plaintiff<td>
Jurisdiction<td>
Court<td>
In-House Counsel<td>
# of Pltfs<td>
Status<td>BP Billing Breakdown</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</HTML>
--------------------------------------------------------------------

10. Build and run the application. Now we can see the table in MS word.

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #9

P: n/a
Thank you for clearing that up.

I see that you are creating the report in HTML and then
converting it to Word. However, I get all of the data for
the report from an SQL 2000 database. That is why I was
trying to do all of the coding from the code_behind page.

In order to continue to do this I have tried to write the
entire table to a string and pass that string to the aspx
page. This does not work. I am not getting the function
called when the form loads. Here is what I am doing:

<HTML>
<HEAD>
<title>WordForm</title>
<%
'Response.ContentType = "application/vnd.ms-word"
'Response.AddHeader("content-
disposition", "inline; filename=BP_CaseStatus.doc")
%>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1"
name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<asp:Table Runat=server>
<asp:TableRow>
<asp:TableCell><%# getReportTable
() %></asp:TableCell>
</asp:TableRow>
</asp:Table>
</body>
</HTML>
CODE BEHIND

Public Function getReportTable() As String
Dim sUser As String = Mid(Page.User.Identity.Name,
InStr(Page.User.Identity.Name, "\") + 1)
Dim sPath As String =
Request.PhysicalApplicationPath 'gives the path where this
file exists

If Request.QueryString("report") = "Case Status
Report w/ BP Billing Data" Then
Return BPCaseStatusWithBillingData(sUser,
sPath)
End If

End Function

I have a breakpoint on the "If" statement but the debugger
never stops there. The function is never called.

Any ideas why?

Thanks
enak
-----Original Message-----
Hi Enak,

Thank you for your update.

I have already tested your code on my side. Please try the following steps on your side. (I am using Windows XP Pro/VS.NET 2003/IE 6)

1. Create a default web application.

2. Add the following code in Page_Load.

Response.Write("<table width=""100%"">")
Response.Write(" <tr><td align=center><font size=+3>My Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP Cases Status Report</font></tr>")

'==============================================
'MAIN TABLE
'==============================================
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%"" cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of Pltfs<td>Status<td>BP Billing Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'==============================================
'MAIN TABLE
'==============================================
Response.Write("</table>")

3. Build and Run the application.

4. We can see the table we creat.

5. Right click the page and select "View Source". We can see the following HTML code.
----------------------------------------------
<table width="100%"> <tr><td align=center><font size=+3>My Report</font></tr> <tr><td align=center><font size=+3>BP Cases Status Report</font></tr> <tr><td> <table border=0 width="100%" cellspacing=3 cellpadding=0> <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of Pltfs<td>Status<td>BP Billing Breakdown</tr> </table> </tr></table><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1"><input type="hidden" name="__VIEWSTATE"
value="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9 oveFlT" /
<FONT face="Arial"></FONT>
</form>
</body>
</HTML>
----------------------------------------------

6. Then please add the following two statements in Page_Load.
Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

7. Build and run the application again. After click the "Open" button, we can find that only the content between "<HTML>" and "</HTML>" are converted to word. That is the reason of this issue.

8. Then please change the code in Page_Load as the following:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.ContentType = "application/ms-word"
Response.AddHeader("content- disposition", "inline; filename=BP_CaseStatus.doc")
End Sub

9. Change the HTML code of the web form as the following:
---------------------------------------------------------- ----------<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="TestWord.WebForm1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server"> <FONT face="Arial"></FONT>
</form>
<table width="100%">
<tr>
<td align="center"><font size="+3">My Report</font></td> <tr>
<td align="center"><font size="+3">BP Cases Status Report</font></td> <tr>
<td>
<table border="0" width="100%" cellspacing="3" cellpadding="0"> <tr bgcolor="#bbbbbb"> <td> Lead Plaintiff<td> Jurisdiction<td> Court<td> In- House Counsel<td> # of Pltfs<td> Status<td>BP Billing Breakdown</td> </tr>
</table>
</td>
</tr>
</table>
</body>
</HTML>
---------------------------------------------------------- ----------
10. Build and run the application. Now we can see the table in MS word.
Does it answer your question? If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #10

P: n/a
Thank you for clearing that up.

I see that you are creating the report in HTML and then
converting it to Word. However, I get all of the data for
the report from an SQL 2000 database. That is why I was
trying to do all of the coding from the code_behind page.

In order to continue to do this I have tried to write the
entire table to a string and pass that string to the aspx
page. This does not work. I am not getting the function
called when the form loads. Here is what I am doing:

<HTML>
<HEAD>
<title>WordForm</title>
<%
'Response.ContentType = "application/vnd.ms-word"
'Response.AddHeader("content-
disposition", "inline; filename=BP_CaseStatus.doc")
%>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1"
name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<asp:Table Runat=server>
<asp:TableRow>
<asp:TableCell><%# getReportTable
() %></asp:TableCell>
</asp:TableRow>
</asp:Table>
</body>
</HTML>
CODE BEHIND

Public Function getReportTable() As String
Dim sUser As String = Mid(Page.User.Identity.Name,
InStr(Page.User.Identity.Name, "\") + 1)
Dim sPath As String =
Request.PhysicalApplicationPath 'gives the path where this
file exists

If Request.QueryString("report") = "Case Status
Report w/ BP Billing Data" Then
Return BPCaseStatusWithBillingData(sUser,
sPath)
End If

End Function

I have a breakpoint on the "If" statement but the debugger
never stops there. The function is never called.

Any ideas why?

Thanks
enak
-----Original Message-----
Hi Enak,

Thank you for your update.

I have already tested your code on my side. Please try the following steps on your side. (I am using Windows XP Pro/VS.NET 2003/IE 6)

1. Create a default web application.

2. Add the following code in Page_Load.

Response.Write("<table width=""100%"">")
Response.Write(" <tr><td align=center><font size=+3>My Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP Cases Status Report</font></tr>")

'==============================================
'MAIN TABLE
'==============================================
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%"" cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of Pltfs<td>Status<td>BP Billing Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'==============================================
'MAIN TABLE
'==============================================
Response.Write("</table>")

3. Build and Run the application.

4. We can see the table we creat.

5. Right click the page and select "View Source". We can see the following HTML code.
----------------------------------------------
<table width="100%"> <tr><td align=center><font size=+3>My Report</font></tr> <tr><td align=center><font size=+3>BP Cases Status Report</font></tr> <tr><td> <table border=0 width="100%" cellspacing=3 cellpadding=0> <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of Pltfs<td>Status<td>BP Billing Breakdown</tr> </table> </tr></table><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1"><input type="hidden" name="__VIEWSTATE"
value="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9 oveFlT" /
<FONT face="Arial"></FONT>
</form>
</body>
</HTML>
----------------------------------------------

6. Then please add the following two statements in Page_Load.
Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

7. Build and run the application again. After click the "Open" button, we can find that only the content between "<HTML>" and "</HTML>" are converted to word. That is the reason of this issue.

8. Then please change the code in Page_Load as the following:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.ContentType = "application/ms-word"
Response.AddHeader("content- disposition", "inline; filename=BP_CaseStatus.doc")
End Sub

9. Change the HTML code of the web form as the following:
---------------------------------------------------------- ----------<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="TestWord.WebForm1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server"> <FONT face="Arial"></FONT>
</form>
<table width="100%">
<tr>
<td align="center"><font size="+3">My Report</font></td> <tr>
<td align="center"><font size="+3">BP Cases Status Report</font></td> <tr>
<td>
<table border="0" width="100%" cellspacing="3" cellpadding="0"> <tr bgcolor="#bbbbbb"> <td> Lead Plaintiff<td> Jurisdiction<td> Court<td> In- House Counsel<td> # of Pltfs<td> Status<td>BP Billing Breakdown</td> </tr>
</table>
</td>
</tr>
</table>
</body>
</HTML>
---------------------------------------------------------- ----------
10. Build and run the application. Now we can see the table in MS word.
Does it answer your question? If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #11

P: n/a
Hi Enak,

Thank you for your update.

In your case, you need not to create the whole web page from scratch. You
just need to create the tables appropriately by using the
System.Web.UI.WebControls.Table class. After the tables are created, you
then can add them to the controls inheritance tree of the web page by using
the Page.Controls.Add() function.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #12

P: n/a
Hi Jacob,
I have 2 tasks in my application regarding Word doc.

1. Could you please tell me how can I open a word template
at client's system with data(blob) from server database?
2. Clicking on OK button in the form it should save the
modified word doc data into the server?
My email id: ra*************@nunet-tech.com
Thanks in advance,
Raghu.
-----Original Message-----
Hi Enak,

Thank you for your update.

I have already tested your code on my side. Please try the following steps on your side. (I am using Windows XP Pro/VS.NET 2003/IE 6)

1. Create a default web application.

2. Add the following code in Page_Load.

Response.Write("<table width=""100%"">")
Response.Write(" <tr><td align=center><font size=+3>My Report</font></tr>")
Response.Write(" <tr><td align=center><font size=+3>BP Cases Status Report</font></tr>")

'==============================================
'MAIN TABLE
'==============================================
Response.Write(" <tr><td>")
Response.Write(" <table border=0 width=""100%"" cellspacing=3 cellpadding=0>")
Response.Write(" <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of Pltfs<td>Status<td>BP Billing Breakdown</tr>")
Response.Write(" </table>")
Response.Write(" </tr>")
'==============================================
'MAIN TABLE
'==============================================
Response.Write("</table>")

3. Build and Run the application.

4. We can see the table we creat.

5. Right click the page and select "View Source". We can see the following HTML code.
----------------------------------------------
<table width="100%"> <tr><td align=center><font size=+3>My Report</font></tr> <tr><td align=center><font size=+3>BP Cases Status Report</font></tr> <tr><td> <table border=0 width="100%" cellspacing=3 cellpadding=0> <tr bgcolor=#bbbbbb><td>Lead
Plaintiff<td>Jurisdiction<td>Court<td>In-House Counsel<td># of Pltfs<td>Status<td>BP Billing Breakdown</tr> </table> </tr></table><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1"><input type="hidden" name="__VIEWSTATE"
value="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9 oveFlT" /
<FONT face="Arial"></FONT>
</form>
</body>
</HTML>
----------------------------------------------

6. Then please add the following two statements in Page_Load.
Response.ContentType = "application/ms-word"
Response.AddHeader("content-disposition", "inline;
filename=BP_CaseStatus.doc")

7. Build and run the application again. After click the "Open" button, we can find that only the content between "<HTML>" and "</HTML>" are converted to word. That is the reason of this issue.

8. Then please change the code in Page_Load as the following:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.ContentType = "application/ms-word"
Response.AddHeader("content- disposition", "inline; filename=BP_CaseStatus.doc")
End Sub

9. Change the HTML code of the web form as the following:
---------------------------------------------------------- ----------<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="TestWord.WebForm1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server"> <FONT face="Arial"></FONT>
</form>
<table width="100%">
<tr>
<td align="center"><font size="+3">My Report</font></td> <tr>
<td align="center"><font size="+3">BP Cases Status Report</font></td> <tr>
<td>
<table border="0" width="100%" cellspacing="3" cellpadding="0"> <tr bgcolor="#bbbbbb"> <td> Lead Plaintiff<td> Jurisdiction<td> Court<td> In- House Counsel<td> # of Pltfs<td> Status<td>BP Billing Breakdown</td> </tr>
</table>
</td>
</tr>
</table>
</body>
</HTML>
---------------------------------------------------------- ----------
10. Build and run the application. Now we can see the table in MS word.
Does it answer your question? If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.