#region
object oMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application WordApp;
Microsoft.Office.Interop.Word.Document WordDoc;
WordApp = new Microsoft.Office.Interop.Word.Application();
WordApp.Visible = true;
WordDoc = WordApp.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
object oEndOfDoc = "\\endofdoc";
Microsoft.Office.Interop.Word.Range wrdRng;
//Insert a chart.
Microsoft.Office.Interop.Word.InlineShape oShape;
object oClassType = "MSGraph.Chart";
wrdRng = WordDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
//Demonstrate use of late bound oChart and oChartApp objects to manipulate the chart object with MSGraph.
object oChart;
object oChartApp;
oChart = oShape.OLEFormat.Object;
oChartApp = oChart.GetType().InvokeMember("Application", BindingFlags.GetProperty, null, oChart, null);
//Change the chart type to Line.
object[] Parameters = new Object[1];
Parameters[0] = 4; //xlLine = 4
oChart.GetType().InvokeMember("ChartType", BindingFlags.SetProperty, null, oChart, Parameters);
Microsoft.Office.Interop.Graph.Chart objChart = (Microsoft.Office.Interop.Graph.Chart)oShape.OLEFormat.Object;
objChart.ChartType = Microsoft.Office.Interop.Graph.XlChartType.xlColumnClustered;
Microsoft.Office.Interop.Graph.DataSheet dataSheet;
dataSheet = objChart.Application.DataSheet;
dataSheet.Cells[1, 2] = "第一季度";
dataSheet.Cells[1, 3] = "第二季度";
dataSheet.Cells[1, 4] = "第三季度";
dataSheet.Cells[1, 5] = "第四季度";
dataSheet.Cells[2, 1] = "东部";
dataSheet.Cells[2, 2] = "50";
dataSheet.Cells[2, 3] = "40";
dataSheet.Cells[2, 4] = "50";
dataSheet.Cells[2, 5] = "50";
dataSheet.Cells[3, 1] = "西部";
dataSheet.Cells[3, 2] = "60";
dataSheet.Cells[3, 3] = "70";
dataSheet.Cells[3, 4] = "80";
dataSheet.Cells[3, 5] = "60";
dataSheet.Cells[4, 1] = "中部";
dataSheet.Cells[4, 2] = "50";
dataSheet.Cells[4, 3] = "40";
dataSheet.Cells[4, 4] = "50";
dataSheet.Cells[4, 5] = "50";
objChart.Application.Update();
//Update the chart image and quit MSGraph.
oChartApp.GetType().InvokeMember("Update", BindingFlags.InvokeMethod, null, oChartApp, null);
oChartApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, null, oChartApp, null);
//... If desired, you can proceed from here using the Microsoft Graph
//Object model on the oChart and oChartApp objects to make additional
//changes to the chart.
//Set the width of the chart.
oShape.Width = WordApp.InchesToPoints(6.25f);
oShape.Height = WordApp.InchesToPoints(3.57f);
//Add text after the chart.
wrdRng = WordDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
wrdRng.InsertParagraphAfter();
wrdRng.InsertAfter("THE END.");
#endregion
导出文字以及表格:
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; //endofdoc是预定义的bookmark
//创建一个document.
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
//oWord.Selection.Font.Bold = 700;
//oWord.Selection.Font.Size = 12;
//oWord.Selection.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
//oWord.Selection.Text = "班级成绩统计单";
object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
//在document的开始部分添加一个paragraph.
Microsoft.Office.Interop.Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "岗位行为指针评估报告 ";
oPara1.Range.Font.Size = 14;
oPara1.Range.Font.Bold = 50;
oPara1.Format.SpaceAfter = 8; //24 pt 行间距
oPara1.Range.InsertParagraphAfter();
在当前document的最后添加一个paragraph
//Microsoft.Office.Interop.Word.Paragraph oPara2;
//oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
//oPara2.Range.Text = "Heading 2";
//oPara2.Format.SpaceAfter = 6;
//oPara2.Range.InsertParagraphAfter();
//接着添加一个paragraph
Microsoft.Office.Interop.Word.Paragraph oPara3;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara3 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara3.Range.Text = "一.评估情况";
oPara3.Range.Font.Bold = 20;
oPara3.Range.Font.Size = 11;
//oPara3.Format.SpaceAfter = 5;
oPara3.Range.InsertParagraphAfter();
Microsoft.Office.Interop.Word.Paragraph oPara14;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara14 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara14.Range.Text = "参与本次评估的情况如下:";
oPara14.Range.Font.Bold = 0;
oPara14.Range.Font.Size = 11;
//oPara14.Format.SpaceAfter = 5;
oPara14.Range.InsertParagraphAfter();
//自评耗时:15 分钟,上级评估耗时:20 分钟
Microsoft.Office.Interop.Word.Paragraph oPara15;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara15 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara15.Range.Text = "自评耗时:15 分钟,上级评估耗时:20 分钟";
oPara15.Range.Font.Bold = 0;
oPara15.Format.SpaceAfter = 8;
oPara15.Range.Font.Size = 11;
oPara15.Range.InsertParagraphAfter();
//Microsoft.Office.Interop.Word.Table newTable = oDoc.Tables.Add(oWord.Selection.Range, 12, 3, ref oMissing,ref oMissing);
Microsoft.Office.Interop.Word.Paragraph oPara16;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara16 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara16.Range.Text = "二、评估结果:";
oPara16.Range.Font.Bold = 20;
oPara16.Format.SpaceAfter = 5;
oPara16.Range.InsertParagraphAfter();
Microsoft.Office.Interop.Word.Paragraph oPara17;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara17 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara17.Range.Text = "1、此次评估共涉及6 个指标,每个指标5.0分,满分为30.0 分,共 24 条行为指针,每条行为指针最低1.0分,上限5.0分,无法评价为0.0分。行为指针按重要性匹配权重,其中非常重要的指标权重为4.0、比较重要的指标权重为2.0、重要的指标权重为1.0,三类行为指针数量各占总数量的1/3 。评估结果为指标得分的加和,匹配度为评估得分与满分的百分比,最大为100%。";
oPara17.Range.Font.Bold = 0;
oPara17.Range.Font.Size = 11;
oPara17.Format.SpaceAfter = 5;
oPara17.Range.InsertParagraphAfter();
Microsoft.Office.Interop.Word.Paragraph oPara18;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara18 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara18.Range.Text = "被评估者王磊的评估结果如下:";
oPara18.Range.Font.Bold = 0;
oPara18.Format.SpaceAfter = 24;
oPara18.Range.InsertParagraphAfter();
//
Microsoft.Office.Interop.Word.Table oTable;
Microsoft.Office.Interop.Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oTable = oDoc.Tables.Add(wrdRng, 4, 4, ref oMissing, ref oMissing);
oTable.Range.ParagraphFormat.SpaceAfter = 24;
int r, c;
string strText = "";
//oTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
oTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
oTable.Cell(1, 1).Range.Text = "统计维度";
oTable.Cell(1, 2).Range.Text = "评估得分";
oTable.Cell(1, 3).Range.Text = "匹配度";
oTable.Cell(1, 4).Range.Text = "备注";
oTable.Cell(2, 1).Range.Text = "自评";
oTable.Cell(3, 1).Range.Text = "上级评估";
oTable.Cell(4, 1).Range.Text = "加权(自评(4 )与上级(6 )";
oTable.Rows[1].Range.Font.Bold = 1;
oTable.Rows[1].Range.Font.Italic = 1;
//接着添加一些文字 统计维度 评估得分 匹配度 备注
Microsoft.Office.Interop.Word.Paragraph oPara19;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara19 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara19.Range.InsertParagraphBefore();
oPara19.Range.Text = "2、评估明细如下:指标按加权得分从高到低排序,行为指针按重要性及加权得分从高到低 排序";
oPara19.Format.SpaceAfter = 24;
oPara19.Range.InsertParagraphAfter();
Microsoft.Office.Interop.Word.Table TableA;
Microsoft.Office.Interop.Word.Range wnd = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
TableA = oDoc.Tables.Add(wnd, 12, 6, ref oMissing, ref oMissing);
TableA.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
//TableA.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
//TableA.Borders.InsideLineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt;
//TableA.Borders.OutsideLineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth150pt;
TableA.Rows[1].Range.Font.Bold = 1;
TableA.Rows[1].Range.Font.Italic = 1;
TableA.Cell(1, 1).Range.Text = "指标/行为指针";
TableA.Cell(1, 2).Range.Text = "重要性";
TableA.Cell(1, 3).Range.Text = "上级评估(40%)";
TableA.Cell(1, 4).Range.Text = "自评(60%)";
TableA.Cell(1, 5).Range.Text = "加权得分";
TableA.Cell(1, 6).Range.Text = "差值(上级-自评)";
TableA.Cell(2, 1).Range.Text = "沟通能力";
TableA.Cell(3, 1).Range.Text = "能够选择合适的沟通方式,准确传递信息";
TableA.Cell(4, 1).Range.Text = "有效引发对方的共鸣,促使沟通的顺利进行";
TableA.Cell(5, 1).Range.Text = "在沟通中能够意识到产生分歧的关键所在,双向沟通,达成共识";
TableA.Cell(6, 1).Range.Text = "文字精简,传递准确的意思和适度的情感";
TableA.Cell(7, 1).Range.Text = "能够主动的协调,提供充足的相关信息及处理建议,并主动追踪进度";
TableA.Cell(8, 1).Range.Text = "理解自己所承担的工作任务和他人工作的关系 ";
TableA.Cell(9, 1).Range.Text = "在资源不足或匮乏的情况下,能通过各种途径寻找所需要的资源";
TableA.Cell(10, 1).Range.Text = "在规定时间节点内,按量保质完成任务、工作";
TableA.Cell(11, 1).Range.Text = "能够根据常规举措主动处理问题,努力解决困难";
TableA.Cell(12, 1).Range.Text = "总结、积累实践案例,提炼并制定响应及备用的解决方案";
TableA.Cell(13, 1).Range.Text = "归纳、提炼相关的问题,从中总结出团队面临的系列难题,认识到这些问题之间的关联以及对未来的潜在影响";
TableA.Cell(14, 1).Range.Text = "能够主动学习、思考、总结更好的问题解决路径";