[vb.code]
* Write This Code in Button Click Event.
* img1,2,3,4 variable is used to get and store the image name which is stored in the session.
* My Scenario was export all four chart control images into one ms-word file.
* Here all image name are unique and stored into the session variable.
Protected Sub btnExportAllChart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportAllChart.Click
Dim serverurl As String = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/TempImageFiles/"
Dim img1 As String = serverurl + Session("ImageName1")
Dim img2 As String = serverurl + Session("ImageName2")
Dim img3 As String = serverurl + Session("ImageName3")
Dim img4 As String = serverurl + Session("ImageName4")
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.ContentType = "application/msword"
Dim strFileName As String = FileName+ ".doc"
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName)
Dim strHTMLContent As New StringBuilder
strHTMLContent.Append("<table align='Center'>".ToString())
strHTMLContent.Append("<tr>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img1 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img2 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("</tr>".ToString())
strHTMLContent.Append("<tr>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img3 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img4 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("</tr>".ToString())
strHTMLContent.Append("</table>".ToString())
HttpContext.Current.Response.Write(strHTMLContent)
HttpContext.Current.Response.End()
HttpContext.Current.Response.Flush()
End Sub
OutPut:
* Write This Code in Button Click Event.
* img1,2,3,4 variable is used to get and store the image name which is stored in the session.
* My Scenario was export all four chart control images into one ms-word file.
* Here all image name are unique and stored into the session variable.
Protected Sub btnExportAllChart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportAllChart.Click
Dim serverurl As String = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/TempImageFiles/"
Dim img1 As String = serverurl + Session("ImageName1")
Dim img2 As String = serverurl + Session("ImageName2")
Dim img3 As String = serverurl + Session("ImageName3")
Dim img4 As String = serverurl + Session("ImageName4")
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.ContentType = "application/msword"
Dim strFileName As String = FileName+ ".doc"
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName)
Dim strHTMLContent As New StringBuilder
strHTMLContent.Append("<table align='Center'>".ToString())
strHTMLContent.Append("<tr>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img1 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img2 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("</tr>".ToString())
strHTMLContent.Append("<tr>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img3 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("<td>".ToString())
strHTMLContent.Append("<img src='" + img4 + "' width='500' height='400'/>".ToString())
strHTMLContent.Append("</td>".ToString())
strHTMLContent.Append("</tr>".ToString())
strHTMLContent.Append("</table>".ToString())
HttpContext.Current.Response.Write(strHTMLContent)
HttpContext.Current.Response.End()
HttpContext.Current.Response.Flush()
End Sub
OutPut:
Comments
Post a Comment