2011-07-03 34 views
2

我已經嘗試了將mschart保存爲單詞文檔2天。無論我做什麼,我都不能保存圖表。我有一個gridview,我已經保存好了,但不是圖表。如何將mschart保存爲webform中的單詞

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() 
+0

我不認爲它的工作原理是這樣的:你必須使用VS中的office庫來創建一個實際的MS Office文檔。在創建該文檔時,您需要添加從圖表中保存的圖像...然後,將整個文檔流式傳輸到客戶端。 – woohoo

回答

0

嘗試將圖表的RenderType屬性設置爲ImageTag。 然後將您的頁面保存爲word文檔。

相關問題