473,378 Members | 1,391 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.

Creating Word documents on page

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
12 4137
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
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
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
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
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #6
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #7
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #8
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #9
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #10
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #11
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #12
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! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 17 '05 #13

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

Similar topics

6
by: campwes | last post by:
Hey, all. I'm trying to develop a C# app that creates Word 2003 mail merge documents with an Oracle 9i database as the datasource. I used the following as an example of how I can start out: ...
15
by: Caversham | last post by:
Is there any macro / other tool - free or commercial - that can split long Word docs into multiple XHTML pages? Any comments on the quality/effectiveness of suitable products also welcomed.
0
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather...
0
by: Raj Singh | last post by:
I am facing a problem with Visual C# 2003 and MS Word XP. I am using a customized template for Word and in that template I have defined some bookmarks. I am trying to create a Word document based...
7
by: Zeke | last post by:
I'm using the following code to create word document but the problem is if you go to task manager you'll see a WINWORD.EXE process is running but not the application, here is the code: ...
3
by: m3ckon | last post by:
Hi there, I can succesfully create a word doc from my asp.net page, but I have 2 issues I need to resolve in order to use it in my app: 1) Creating a table: I seem unable to create a table,...
2
by: elziko | last post by:
I'm trying to create a new table in word from a DataTable (sourceTable): objDoc.tables.Add(Range:=objDoc.Range, NumRows:=sourceTable.Rows.Count, NumColumns:=sourceTable.Columns.Count,...
0
by: Eagle | last post by:
I am trying to change the linewidth of a page border, and keeping getting an error at the "wdLineWith075pt" For some reason, it only accepts the value of 24 like the left border. Yet when I print...
0
by: PracticalApps | last post by:
I looked to find a canned solution to create a Word document in my application and just couldn't find anything that just gets to the point. I would think, and I may be making too strong of an...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.