答案 0 :(得分: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();