Pārlūkot izejas kodu

word导出完整

duhongyu 4 gadi atpakaļ
vecāks
revīzija
7dca42eb10

+ 1 - 6
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/Assessment/DataAssessmentController.cs

@@ -16,12 +16,7 @@ namespace CallCenterApi.Interface.Controllers.Assessment
16 16
     {
17 17
         private BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
18 18
         private BLL.T_Data_Assessment dataBLL = new BLL.T_Data_Assessment();
19
-        public ActionResult Download()
20
-        {
21
-            ExportWord np = new ExportWord();
22
-            np.CreateWord("测试");
23
-            return Success("http://192.168.8.9:1042//Upload/Word/工单.doc");
24
-        }
19
+       
25 20
         /// <summary>
26 21
         /// 获取月绩效考核数据
27 22
         /// </summary>

+ 47 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -6977,7 +6977,53 @@ namespace CallCenterApi.Interface.Controllers.workorder
6977 6977
                 return Error("参数传输失败");
6978 6978
             }
6979 6979
         }
6980
-
6980
+        /// <summary>
6981
+        /// 导出word
6982
+        /// </summary>
6983
+        /// <returns></returns>
6984
+        [Authority]
6985
+        public ActionResult ExportWorkOrder()
6986
+        {
6987
+            int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
6988
+            Model.T_Sys_UserAccount userModel = userBLL.GetModel(userId);
6989
+            string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
6990
+            if (!string.IsNullOrEmpty(strworkorderid))
6991
+            {
6992
+                string sql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,"
6993
+                    + "dbo.GetAreaName(F_SourceArea) as AreaName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) as KeyName,dbo.GetDeptName(F_MainDeptId) deptname ," + "F_DeptIdIsSms = (select F_IsSms  from T_Sys_Department where F_DeptId =a.F_MainDeptId)"
6994
+                      + " from T_Bus_WorkOrder a WITH(NOLOCK) where F_WorkOrderId ='" + strworkorderid + "'";
6995
+                var dt = DbHelperSQL.Query(sql).Tables[0];
6996
+                if (dt.Rows.Count > 0)
6997
+                {
6998
+                    if (dt.Rows[0]["F_IsProtect"] != null && (userModel.F_RoleCode == "WLDW" || userModel.F_RoleCode == "EJWLDW" || userModel.F_RoleCode == "DBZY"))
6999
+                    {
7000
+                        string isp = dt.Rows[0]["F_IsProtect"].ToString();
7001
+                        if (isp == "1")
7002
+                        {
7003
+                            dt.Rows[0]["F_CusName"] = "";
7004
+                            dt.Rows[0]["F_CusPhone"] = "";
7005
+                            dt.Rows[0]["F_ConPhone"] = "";
7006
+                        }
7007
+                    }
7008
+                    string jbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName,dbo.GetDictionaryNames(F_StandardIDS) as StandardNames  "
7009
+                                    + "from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime desc";
7010
+                    var jbdt = DbHelperSQL.Query(jbsql).Tables[0];
7011
+                    ExportWord np = new ExportWord();
7012
+                    np.CreateWord(dt ,jbdt,userModel .F_UserCode  );
7013
+                    string url = dt.Rows[0]["F_WorkOrderId"].ToString();
7014
+                    url = "http://192.168.8.9:1042//Upload/Word/工单" + url + ".doc";
7015
+                    return Success(url);
7016
+                }
7017
+                else
7018
+                {
7019
+                    return Error("获取失败");
7020
+                }
7021
+            }
7022
+            else
7023
+            {
7024
+                return Error("参数传输失败");
7025
+            }
7026
+        }
6981 7027
         /// <summary>
6982 7028
         /// 获取工单信息
6983 7029
         /// </summary>

+ 152 - 149
CallCenterCommon/CallCenter.Utility/word/ExportWord.cs

@@ -1,150 +1,153 @@
1
-using System;
2
- using System.Collections.Generic;
3
-  using System.Linq;
4
-  using System.Web;
5
-  using System.Data;
6
-  using System.IO;
7
-using MSWord = Microsoft.Office.Interop.Word;
8
-/// <summary>
9
-///DaoChuWord 的摘要说明
10
-/// </summary>
11
-public class ExportWord
12
-  {
13
-      public string CreateWord(string name)
14
-      {
15
-            string message = "";
16
-            Object Nothing = System.Reflection.Missing.Value;
17
-            object filename = name;  //文件保存路径  
18
-                                  //创建Word文档 
19
-            Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
20
-              Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
21
-              WordApp.Selection.PageSetup.LeftMargin = 50f;
22
-              WordApp.Selection.PageSetup.RightMargin = 50f;
23
-              WordApp.Selection.PageSetup.PageWidth = 650f;  //页面宽度 
24
-              WordDoc.ActiveWindow.Selection.Font.Bold = 2;
25
-             WordApp.Selection.ParagraphFormat.LineSpacing = 13f;//设置文档的行间距      
26
-              //移动焦点并换行 
27
-             object count = 14;
28
-              object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
29
-             WordApp.Selection.ParagraphFormat.LineSpacing = 18f;
30
-              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
31
-              WordApp.Selection.MoveDown(ref WdLine, ref count, ref Nothing);//移动焦点 
32
-              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
33
-              WordApp.Selection.TypeParagraph();//插入段落 
34
-              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
35
-              WordApp.Selection.Font.Size = 18f;
36
-              object missing = System.Reflection.Missing.Value;
37
-              object WdLine2 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;   
38
-              WordApp.Selection.Text = "安 阳 市 12345 政 务 服 务 热 线 交 办 单";
39
-              WordApp.Selection.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceSingle;//单倍行距
40
-              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
41
-              WordApp.Selection.MoveDown(ref WdLine, ref count, ref Nothing);//移动焦点 
42
-              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
43
-              WordApp.Selection.TypeParagraph();//插入段落 
44
-              WordApp.Selection.Font.Size = 10.5f;
45
-              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
46
-              WordApp.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
47
-              //文档中创建表格 
48
-             Microsoft.Office.Interop.Word.Table newTable = WordDoc.Tables.Add(WordApp.Selection.Range, 18, 9, ref Nothing, ref Nothing);
49
-             //设置表格样式 
50
-            for (int i = 1; i < 10; i ++)
51
-            {
52
-            if (i ==9)
53
-            {
54
-                newTable.Columns[i].Width = 80f;
55
-            }
56
-            else  
57
-            newTable.Columns[i].Width = 60f;
58
-            }
59
-            for (int i=1;i<19;i++)
60
-           {
61
-            newTable.Rows[i].Height = 30f;
62
-           }
63
-            //表格外线
64
-        newTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
65
-        //表格内线
66
-        newTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
67
-             //垂直居中
68
-            object unit = Microsoft.Office.Interop.Word.WdUnits.wdLine;
69
-             object countjz = 1;
70
-             WordApp.Selection.MoveEnd(ref unit, ref countjz);
71
-            WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//垂直居中 
72
-           //填充表格内容 第一行
73
-             newTable.Cell(1, 1).Range.Text = "事项编号";
74
-             newTable.Cell(1, 1).Merge(newTable.Cell(2, 1));
75
-             newTable.Cell(1, 2).Range.Text ="";//工单编号
76
-             newTable.Cell(1, 2).Merge(newTable.Cell(2, 3));
77
-             newTable.Cell(1, 3).Range.Text = "工单来源";
78
-             newTable.Cell(1, 4).Range.Text = "";
79
-             newTable.Cell(1, 5).Range.Text = "办理时限";
80
-             newTable.Cell(1, 6).Range.Text = "";
81
-             newTable.Cell(1, 7).Range.Text = "联系电话";
82
-             newTable.Cell(2, 3).Range.Text = "签收时间";
83
-             newTable.Cell(2, 4).Range.Text = "";
84
-             newTable.Cell(2, 5).Range.Text = "办理时间";
85
-             newTable.Cell(2, 6).Range.Text = "";
86
-             newTable.Cell(2, 7).Range.Text = "来电人";
87
-             newTable.Cell(3, 1).Range.Text = "事项区域";
88
-            newTable.Cell(3, 2).Range.Text = "";
89
-            newTable.Cell(3, 2).Merge(newTable.Cell(3, 9));
90
-             //填充表格内容 第四行
91
-            newTable.Cell(4, 1).Range.Text = "内容摘要";
92
-            newTable.Cell(4, 1).Merge(newTable.Cell(7, 1));
93
-            newTable.Cell(4, 2).Range.Text ="  ";
94
-            newTable.Cell(4, 2).Merge(newTable.Cell(7, 9));
95
-           newTable.Cell(5, 1).Range.Text = "承办单位";
96
-           newTable.Cell(5, 2).Range.Text = "  ";
97
-           newTable.Cell(5, 2).Merge(newTable.Cell(5, 4));
98
-           newTable.Cell(5, 3).Range.Text = "协办单位";
99
-           newTable.Cell(5, 4).Range.Text = "  ";
100
-           newTable.Cell(5, 4).Merge(newTable.Cell(5, 7));
101
-        newTable.Cell(6, 1).Range.Text = "调度意见";
102
-        newTable.Cell(6, 1).Merge(newTable.Cell(8, 1));
103
-        newTable.Cell(6, 2).Range.Text = "  ";
104
-        newTable.Cell(6, 2).Merge(newTable.Cell(8, 9));
105
-        newTable.Cell(7, 1).Range.Text = "承办意见";
106
-        newTable.Cell(7, 1).Merge(newTable.Cell(8, 1));
107
-        newTable.Cell(7, 2).Range.Text = "  ";
108
-        newTable.Cell(7, 2).Merge(newTable.Cell(8, 9));
109
-        newTable.Cell(8, 1).Range.Text = "领导批示";
110
-        newTable.Cell(8, 1).Merge(newTable.Cell(9, 1));
111
-        newTable.Cell(8, 2).Range.Text = "";
112
-        newTable.Cell(8, 2).Merge(newTable.Cell(9, 9));
113
-        newTable.Cell(9, 1).Range.Text = "处理结果";
114
-        newTable.Cell(9, 1).Merge(newTable.Cell(12, 1));
115
-        newTable.Cell(9, 2).Range.Text = "  ";
116
-        newTable.Cell(9, 2).Merge(newTable.Cell(12, 9));
117
-       string FileName = "/Upload/Word/" + "/word.png";
118
-        FileName = HttpContext.Current.Server.MapPath("..") + FileName;
119
-        newTable.Cell(6, 2).Select();//选中一行 
120
-        object LinkToFile = false;
121
-         object SaveWithDocument = true;
122
-       object Anchor = WordDoc.Application.Selection.Range;
123
-        WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
124
-       WordDoc.Application.ActiveDocument.InlineShapes[1].Width = 110f;//图片宽度 
125
-       WordDoc.Application.ActiveDocument.InlineShapes[1].Height =100f;//图片高 
126
-        WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
127
-        //将图片设置浮动在文字上方
128
-        WordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape().WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;
129
-        WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;//水平居中 
130
-        object unite = MSWord.WdUnits.wdStory;
131
-        WordApp.Selection.EndKey(ref unite, ref Nothing); //将光标移动到文档末尾
132
-        WordDoc.Content.InsertAfter("联系电话:" + ""+"                        "
133
-            +"    审核员"+""+"                   " +"       调度员");
134
-        //WdSaveFormat为Word 2003文档的保存格式
135
-        object format = MSWord.WdSaveFormat.wdFormatDocument;// office 2007就是wdFormatDocumentDefault
136
-        object path;
137
-       
138
-        path = "/Upload/Word/"+ "/工单.doc";
139
-        path = HttpContext.Current.Server.MapPath("..") + path;
140
-        if (File.Exists((string)path))
141
-        {
142
-            File.Delete((string)path);
143
-        }
144
-        //将wordDoc文档对象的内容保存为doc文档
145
-        WordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
146
-        WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
147
-        WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
148
-            return message;
149
-     }
1
+using System;
2
+ using System.Collections.Generic;
3
+  using System.Linq;
4
+  using System.Web;
5
+  using System.Data;
6
+  using System.IO;
7
+using MSWord = Microsoft.Office.Interop.Word;
8
+/// <summary>
9
+///DaoChuWord 的摘要说明
10
+/// </summary>
11
+public class ExportWord
12
+  {
13
+      public string CreateWord(DataTable dt, DataTable jbdata,string usercode)
14
+      {
15
+            string message = "";
16
+            Object Nothing = System.Reflection.Missing.Value;
17
+            Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
18
+              Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
19
+              WordApp.Selection.PageSetup.LeftMargin = 50f;
20
+              WordApp.Selection.PageSetup.RightMargin = 50f;
21
+              WordApp.Selection.PageSetup.PageWidth = 650f;  //页面宽度 
22
+              WordDoc.ActiveWindow.Selection.Font.Bold = 2;
23
+             WordApp.Selection.ParagraphFormat.LineSpacing = 13f;//设置文档的行间距      
24
+              //移动焦点并换行 
25
+             object count = 14;
26
+              object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
27
+             WordApp.Selection.ParagraphFormat.LineSpacing = 18f;
28
+              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
29
+              WordApp.Selection.MoveDown(ref WdLine, ref count, ref Nothing);//移动焦点 
30
+              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
31
+              WordApp.Selection.TypeParagraph();//插入段落 
32
+              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
33
+              WordApp.Selection.Font.Size = 18f;
34
+              object missing = System.Reflection.Missing.Value;
35
+              object WdLine2 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;   
36
+              WordApp.Selection.Text = "安 阳 市 12345 政 务 服 务 热 线 交 办 单";
37
+              WordApp.Selection.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceSingle;//单倍行距
38
+              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
39
+              WordApp.Selection.MoveDown(ref WdLine, ref count, ref Nothing);//移动焦点 
40
+              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
41
+              WordApp.Selection.TypeParagraph();//插入段落 
42
+              WordApp.Selection.Font.Size = 10.5f;
43
+              WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
44
+              WordApp.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack;
45
+              //文档中创建表格 
46
+             Microsoft.Office.Interop.Word.Table newTable = WordDoc.Tables.Add(WordApp.Selection.Range, 18, 9, ref Nothing, ref Nothing);
47
+             //设置表格样式 
48
+            for (int i = 1; i < 10; i ++)
49
+            {
50
+            if (i ==9)
51
+            {
52
+                newTable.Columns[i].Width = 80f;
53
+            }
54
+            else  
55
+            newTable.Columns[i].Width = 60f;
56
+            }
57
+            for (int i=1;i<19;i++)
58
+           {
59
+            newTable.Rows[i].Height = 30f;
60
+           }
61
+            //表格外线
62
+        newTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
63
+        //表格内线
64
+        newTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
65
+             //垂直居中
66
+            object unit = Microsoft.Office.Interop.Word.WdUnits.wdLine;
67
+             object countjz = 1;
68
+             WordApp.Selection.MoveEnd(ref unit, ref countjz);
69
+            WordApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//垂直居中 
70
+             newTable.Cell(1, 1).Range.Text = "事项编号";
71
+             newTable.Cell(1, 1).Merge(newTable.Cell(2, 1));
72
+             newTable.Cell(1, 2).Range.Text = dt.Rows[0]["F_WorkOrderId"].ToString();
73
+             newTable.Cell(1, 2).Merge(newTable.Cell(2, 3));
74
+             newTable.Cell(1, 3).Range.Text = "工单来源";
75
+             newTable.Cell(1, 4).Range.Text = dt.Rows[0]["SourceName"].ToString();
76
+             newTable.Cell(1, 5).Range.Text = "办理时限";
77
+             newTable.Cell(1, 6).Range.Text = jbdata.Rows[0]["F_LimitTime"].ToString(); 
             newTable.Cell(1, 7).Range.Text = "联系电话";
78
+           newTable.Cell(1, 8).Range.Text = dt.Rows[0]["F_CusPhone"].ToString();
79
+             newTable.Cell(2, 3).Range.Text = "签收时间";
80
+           newTable.Cell(2, 4).Range.Text = jbdata.Rows[0]["F_SureTime"].ToString();
             newTable.Cell(2, 5).Range.Text = "办理时间";
81
+             newTable.Cell(2, 6).Range.Text = dt.Rows[0]["F_CreateTime"].ToString();
82
+        newTable.Cell(2, 7).Range.Text = "来电人";
83
+        newTable.Cell(2, 8).Range.Text = dt.Rows[0]["F_CusName"].ToString();
84
+        newTable.Cell(3, 1).Range.Text = "事项区域";
85
+            newTable.Cell(3, 2).Range.Text = dt.Rows[0]["F_SourceAddress"].ToString();
86
+        newTable.Cell(3, 2).Merge(newTable.Cell(3, 9));
87
+            newTable.Cell(4, 1).Range.Text = "内容摘要";
88
+            newTable.Cell(4, 1).Merge(newTable.Cell(7, 1));
89
+        if (dt.Rows[0]["F_Content"] != null && dt.Rows[0]["F_Content"].ToString() != "")
90
+        {
91
+            newTable.Cell(4, 2).Range.Text = dt.Rows[0]["F_Content"].ToString();
92
+        }
93
+        else
94
+        {
95
+            newTable.Cell(4, 2).Range.Text = dt.Rows[0]["F_ComContent"].ToString();
96
+        }
97
+            newTable.Cell(4, 2).Merge(newTable.Cell(7, 9));
98
+           newTable.Cell(5, 1).Range.Text = "承办单位";
99
+           newTable.Cell(5, 2).Range.Text = jbdata.Rows[0]["DeptName"].ToString();
100
+        newTable.Cell(5, 2).Merge(newTable.Cell(5, 4));
101
+           newTable.Cell(5, 3).Range.Text = "协办单位";
102
+           newTable.Cell(5, 4).Range.Text = jbdata.Rows[0]["OtherDeptName"].ToString();
103
+        newTable.Cell(5, 4).Merge(newTable.Cell(5, 7));
104
+        newTable.Cell(6, 1).Range.Text = "调度意见";
105
+        newTable.Cell(6, 1).Merge(newTable.Cell(8, 1));
106
+        newTable.Cell(6, 2).Range.Text = jbdata.Rows[0]["F_AssignedOpinion"].ToString();
107
+        newTable.Cell(6, 2).Merge(newTable.Cell(8, 9));
108
+        newTable.Cell(7, 1).Range.Text = "承办意见";
109
+        newTable.Cell(7, 1).Merge(newTable.Cell(8, 1));
110
+        newTable.Cell(7, 2).Range.Text = "  ";
111
+        newTable.Cell(7, 2).Merge(newTable.Cell(8, 9));
112
+        newTable.Cell(8, 1).Range.Text = "领导批示";
113
+        newTable.Cell(8, 1).Merge(newTable.Cell(9, 1));
114
+        newTable.Cell(8, 2).Range.Text = "";
115
+        newTable.Cell(8, 2).Merge(newTable.Cell(9, 9));
116
+        newTable.Cell(9, 1).Range.Text = "处理结果";
117
+        newTable.Cell(9, 1).Merge(newTable.Cell(12, 1));
118
+        newTable.Cell(9, 2).Range.Text = dt.Rows[0]["F_Result"].ToString();
119
+        newTable.Cell(9, 2).Merge(newTable.Cell(12, 9));
120
+       string FileName = "/Upload/Word/" + "/word.png";
121
+        FileName = HttpContext.Current.Server.MapPath("..") + FileName;
122
+        newTable.Cell(6, 2).Select();//选中一行 
123
+        object LinkToFile = false;
124
+         object SaveWithDocument = true;
125
+       object Anchor = WordDoc.Application.Selection.Range;
126
+        WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
127
+       WordDoc.Application.ActiveDocument.InlineShapes[1].Width = 110f;//图片宽度 
128
+       WordDoc.Application.ActiveDocument.InlineShapes[1].Height =100f;//图片高 
129
+        WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
130
+        //将图片设置浮动在文字上方
131
+        WordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape().WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;
132
+        WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;//水平居中 
133
+        object unite = MSWord.WdUnits.wdStory;
134
+        WordApp.Selection.EndKey(ref unite, ref Nothing); //将光标移动到文档末尾
135
+        WordDoc.Content.InsertAfter("联系电话:" + "(0372)12345" + "                        "
136
+            +"    审核员:"+ usercode + "                   " +"       调度员:"+ jbdata .Rows[0]["F_CreateUser"].ToString());
137
+        //WdSaveFormat为Word 2003文档的保存格式
138
+        object format = MSWord.WdSaveFormat.wdFormatDocument;// office 2007就是wdFormatDocumentDefault
139
+        object path;
140
+       
141
+        path = "/Upload/Word/"+ "/工单"+ dt.Rows[0]["F_WorkOrderId"].ToString() + ".doc";
142
+        path = HttpContext.Current.Server.MapPath("..") + path;
143
+        if (File.Exists((string)path))
144
+        {
145
+            File.Delete((string)path);
146
+        }
147
+        //将wordDoc文档对象的内容保存为doc文档
148
+        WordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
149
+        WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
150
+        WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
151
+            return message;
152
+     }
150 153
 }