Creating Word documents on page

Discussion in 'ASP .Net' started by enak, Oct 24, 2003.

  1. enak

    enak Guest

    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
     
    enak, Oct 24, 2003
    #1
    1. Advertising

  2. enak

    Ivan Guest

    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
    >
    >
    >
    >
    >.
    >
     
    Ivan, Oct 24, 2003
    #2
    1. Advertising

  3. enak

    Guest Guest

    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
    >>
    >>
    >>
    >>
    >>.
    >>

    >.
    >
     
    Guest, Oct 24, 2003
    #3
  4. enak

    Ivan Guest

    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

    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
    >>>
    >>>
    >>>
    >>>
    >>>.
    >>>

    >>.
    >>

    >.
    >
     
    Ivan, Oct 24, 2003
    #4
  5. enak

    enak Guest

    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

    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

    >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
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>.
    >>>>
    >>>.
    >>>

    >>.
    >>

    >.
    >
     
    enak, Oct 24, 2003
    #5
  6. 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.
     
    Jacob Yang [MSFT], Oct 25, 2003
    #6
  7. 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/NewsletterArticle/2003/09/asp200309so_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.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.
     
    Jacob Yang [MSFT], Oct 26, 2003
    #7
  8. enak

    enak Guest

    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/NewsletterArticle/2003/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 Excel
    >http://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.
    >
    >.
    >
     
    enak, Oct 27, 2003
    #8
  9. 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="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9oveFlT" />

    <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.
     
    Jacob Yang [MSFT], Oct 28, 2003
    #9
  10. enak

    enak Guest

    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="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9oveFlT" /
    >
    >
    > <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.
    >
    >.
    >
     
    enak, Oct 28, 2003
    #10
  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.
     
    Jacob Yang [MSFT], Oct 29, 2003
    #11
  12. enak

    Guest Guest

    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:
    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="dDwtMTI3OTMzNDM4NDs7PkHVmr4UQqVvjWev6bWIe9oveFlT" /
    >
    >
    > <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.
    >
    >.
    >
     
    Guest, Nov 5, 2003
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    520
    Juan T. Llibre
    Oct 18, 2006
  2. Brian Cryer

    Creating Word Documents

    Brian Cryer, Feb 1, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    343
    Mark Rae
    Feb 1, 2007
  3. Tom
    Replies:
    2
    Views:
    158
  4. Tony
    Replies:
    2
    Views:
    427
  5. Replies:
    5
    Views:
    1,220
    Mumia W.
    Apr 7, 2007
Loading...

Share This Page