2016-04-04 14 views

答えて

2

最後に私は解決策を得ました。

まず、チャートをPngイメージとして保存しました。

  Chart1.SaveImage(@"D:\Test\Sample1.png", ChartImageFormat.Png); 

次に、PNGイメージを単語にエクスポートしました。

 Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application(); 
     Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Add(); //If you're creating a document 
     oWord.Visible = true; 
     Object oMissing = System.Reflection.Missing.Value; 
     var oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing); 
     oPara1.Range.Text = "Chart Sample"; 
     oPara1.Range.InsertParagraphAfter(); 
     System.Drawing.Image Picture = myimage;*// Assigned saved png image* 
     var oPara2 = oDoc.Content.Paragraphs.Add(ref oMissing); 
     Thread thread = new Thread(() => Clipboard.SetImage(Picture)); 
     thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA 
     thread.Start(); 
     thread.Join(); 

     oPara2.Range.Paste(); 
     oPara2.Range.InsertParagraphAfter(); 
     oDoc.SaveAs(docFilePath); 
     oDoc.Close(); 
     oWord.Quit(); 
関連する問題