I have tried for 2 days saving a mschart to a word document. No matter what I do, I cant save the chart. I have a gridview, and I have saved that fine, but not the chart.
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment;filename=FileName.doc")
Response.ContentEncoding = System.Text.Encoding.Default
Response.ContentType = "application/vnd.word"
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter()
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
' Chart1.SaveImage("C:\temp\chart.jpg", ChartImageFormat.Jpeg)
' GridView1.DataBind()
GridView33.RenderControl(oHtmlTextWriter)
Response.Output.Write(oStringWriter.ToString())
Response.Output.Write(oStringWriter)
'the chart part
Chart1.SaveImage(Server.MapPath("\WebCharts\Chart.Jpeg"))
Dim ms As MemoryStream = New MemoryStream()
Chart1.SaveImage(ms, ChartImageFormat.Bmp)
Dim bm As System.Drawing.Bitmap = New System.Drawing.Bitmap(ms)
Dim strHTMLContent As StringBuilder = New StringBuilder()
strHTMLContent.Append(bm.ToString())
Response.Flush()
Response.End()
Try to set the RenderType property of your chart to ImageTag. Then save your page as a word document.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.