ReportGenerator_old.cs 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MSWord = Microsoft.Office.Interop.Word;
  7. using System.IO;
  8. using System.Reflection;
  9. namespace WpfTest1.Toolkits
  10. {
  11. class ReportGenerator_old
  12. {
  13. /*
  14. * generateReport:生成报告的方法
  15. * 参数:
  16. * patiment:病人对象
  17. * rcd: 报告对象
  18. * cfg 系统Config类
  19. * handFlag:0均没有,1左手,2右手,3双手
  20. * mw: 主界面引用
  21. * expressions:各参数值结果
  22. * rpRecord: RP环节的结果
  23. * generalExpressionResult: 用于自动评价风险的总表达式结果,double
  24. * */
  25. //
  26. public void generateReport(SQLite.Patient patient, SQLite.Record rcd, Config cfg, int handFlag,MainWindow mw, Dictionary<string,double> expressions, SQLite.doctor doct,RPCalculate rpRecord, string generalExpressionResult)
  27. {
  28. String path = Constants.reportPath;
  29. //String now = System.DateTime.Now.ToString("yyyyMMddHHmmss");
  30. /* String picName0 = path + "\\" + "0.jpg";
  31. String picName1 = path + "\\" + "1.jpg";
  32. String picName2 = path + "\\" + "2.jpg";
  33. String picName3 = path + "\\" + "3.jpg";
  34. String picName4 = path + "\\" + "4.jpg";
  35. */
  36. String fileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.r_time.ToString("yyyyMMddHHmmss") + ".doc";
  37. String pdfFileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.r_time.ToString("yyyyMMddHHmmss") + ".pdf";
  38. if (File.Exists(fileName))
  39. {
  40. try
  41. {
  42. File.Delete(fileName);
  43. }
  44. catch (Exception)
  45. {
  46. ;
  47. }
  48. }
  49. FileStream fs = new FileStream(fileName, FileMode.CreateNew);
  50. fs.Close();
  51. int space = 12;
  52. Object oMissing = System.Reflection.Missing.Value;
  53. Microsoft.Office.Interop.Word._Application WordApp = new Microsoft.Office.Interop.Word.Application();
  54. object filename = fileName;
  55. Microsoft.Office.Interop.Word._Document WordDoc = null;
  56. try
  57. {
  58. WordDoc = WordApp.Documents.Open(ref filename, ref oMissing,
  59. ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
  60. ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
  61. WordApp.Visible = false;
  62. //页面设置
  63. WordDoc.PageSetup.PaperSize = MSWord.WdPaperSize.wdPaperA4;//设置纸张样式为A4纸
  64. WordDoc.PageSetup.Orientation = MSWord.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
  65. WordDoc.PageSetup.TopMargin = 57.0f;
  66. WordDoc.PageSetup.BottomMargin = 10.0f;
  67. WordDoc.PageSetup.LeftMargin = 57.0f;
  68. WordDoc.PageSetup.RightMargin = 57.0f;
  69. WordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
  70. WordDoc.PageSetup.FooterDistance = 15.0f;
  71. //设置页眉
  72. WordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
  73. WordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置,其中页眉边距在页面设置中已完成
  74. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
  75. //插入页眉图片(测试结果图片未插入成功)
  76. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
  77. string headerfile = Constants.reportHeadPicPath;
  78. Console.WriteLine(headerfile);
  79. Microsoft.Office.Interop.Word.InlineShape shape1 = WordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref oMissing, ref oMissing, ref oMissing);
  80. shape1.Height = 25;
  81. shape1.Width = 25;
  82. //页眉修改Test
  83. object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
  84. object count = WordDoc.Paragraphs.Count;
  85. object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
  86. string eyeContent = cfg.organization_name;
  87. //第一行
  88. WordApp.Selection.Font.Name = "黑体";
  89. WordApp.Selection.Font.Bold = 1;
  90. WordApp.Selection.Font.Color = MSWord.WdColor.wdColorRed;
  91. WordApp.Selection.Font.Size = 30;
  92. WordApp.Selection.Font.Spacing = 10;
  93. WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(" " + eyeContent + "\n");
  94. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
  95. //第二行
  96. WordApp.Selection.Font.Name = "黑体";
  97. WordApp.Selection.Font.Bold = 1;
  98. WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
  99. WordApp.Selection.Font.Size = 20;
  100. WordApp.Selection.Font.Spacing = 0;
  101. WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("PIH检测报告单" + "\n");
  102. //第一行
  103. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
  104. WordApp.Selection.Font.Name = "黑体";
  105. WordApp.Selection.Font.Bold = 1;
  106. WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
  107. WordApp.Selection.Font.Size = 10;
  108. string currentData = DateTime.Now.ToString("yy/MM/dd");
  109. WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("病案编号:" + rcd.r_id + " " + "检查日期:" + currentData);
  110. //去掉页眉的横线
  111. //WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
  112. //WordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
  113. WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
  114. //页脚
  115. WordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;
  116. WordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryFooter;
  117. //移动光标文档末尾
  118. // object count = WordDoc.Paragraphs.Count;
  119. // object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
  120. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
  121. // 去掉页脚的横线
  122. WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
  123. WordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = true;
  124. //为当前页添加页码
  125. Microsoft.Office.Interop.Word.PageNumbers pns = WordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
  126. pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
  127. pns.HeadingLevelForChapter = 0;
  128. pns.IncludeChapterNumber = false;
  129. pns.RestartNumberingAtSection = false;
  130. pns.StartingNumber = 0;
  131. object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
  132. object first = true;
  133. WordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);
  134. WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
  135. //插入表格
  136. // WordApp.Selection.EndKey(ref WdLine, ref oMissing);
  137. //WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
  138. int tableRow = 6;
  139. int tableColumn = 6;
  140. //定义一个word中的表格对象
  141. MSWord.Table table = WordDoc.Tables.Add(WordApp.Selection.Range, tableRow, tableColumn, ref oMissing, ref oMissing);
  142. table.Range.Font.Size = 10;
  143. table.Range.Font.Bold = 0;
  144. table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
  145. //内线
  146. //table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
  147. table.Columns[1].Width = 70;
  148. table.Columns[2].Width = 120;
  149. table.Columns[3].Width = 60;
  150. table.Columns[4].Width = 70;
  151. table.Columns[5].Width = 80;
  152. //table.Columns[6].Width = 40;
  153. for (int i = 1; i <= 6; i = i + 2)
  154. {
  155. for (int j = 1; j <= 6; j++)
  156. {
  157. table.Cell(j, i).Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft;
  158. }
  159. }
  160. table.Cell(1, 1).Range.Text = "身份证号:";
  161. table.Cell(1, 2).Range.Text = patient.p_record_id;
  162. table.Cell(1, 3).Range.Text = "性别:";
  163. table.Cell(1, 4).Range.Text = "女";
  164. table.Cell(1, 5).Range.Text = "病例号:";
  165. table.Cell(1, 6).Range.Text = patient.p_record_id.ToString();
  166. table.Cell(2, 1).Range.Text = "姓名:";
  167. table.Cell(2, 2).Range.Text = patient.p_name;
  168. table.Cell(2, 3).Range.Text = "年龄:";
  169. if (patient.p_record_id.Length == 18)
  170. {
  171. //假设身份证号合法
  172. string birthday = patient.p_record_id.Substring(6, 8);
  173. //MessageBox.Show(birthday);
  174. if (birthday.Substring(0, 2) == "19" || birthday.Substring(0, 2) == "20")
  175. {
  176. DateTime birthdayDate = new DateTime(Convert.ToInt32(birthday.Substring(0, 4)), Convert.ToInt32(birthday.Substring(4, 2)), Convert.ToInt32(birthday.Substring(6, 2)));
  177. int age = Toolkits.OtherSmallFunction.getAgeByBirthDay(birthdayDate);
  178. table.Cell(2, 4).Range.Text = age.ToString();
  179. }
  180. else
  181. {
  182. table.Cell(2, 4).Range.Text = "--";
  183. }
  184. }
  185. else
  186. {
  187. table.Cell(2, 4).Range.Text = "--";
  188. }
  189. table.Cell(2, 5).Range.Text = "床号:";
  190. table.Cell(2, 6).Range.Text = "--";
  191. table.Cell(3, 1).Range.Text = "身高:";
  192. table.Cell(3, 2).Range.Text = patient.p_height.ToString();
  193. table.Cell(3, 3).Range.Text = "科别:";
  194. table.Cell(3, 4).Range.Text = "产科";
  195. table.Cell(3, 5).Range.Text = "检查部位:";
  196. switch (handFlag)
  197. {
  198. case 0:
  199. table.Cell(3, 6).Range.Text = "□左手 □右手";
  200. break;
  201. case 1:
  202. table.Cell(3, 6).Range.Text = "√左手 □右手";
  203. break;
  204. case 2:
  205. table.Cell(3, 6).Range.Text = "□左手 √右手";
  206. break;
  207. default:
  208. table.Cell(3, 6).Range.Text = "√左手 √右手";
  209. break;
  210. }
  211. table.Cell(4, 1).Range.Text = "体重:";
  212. table.Cell(4, 2).Range.Text = patient.p_weight.ToString();
  213. table.Cell(4, 3).Range.Text = "孕周:";
  214. //table.Cell(4, 4).Range.Text = ((DateTime.Now - patient.pregnancy_date).Days / 7 + 1).ToString(); ;
  215. table.Cell(4, 5).Range.Text = "孕次:";
  216. //table.Cell(4, 6).Range.Text = patient.pregnancy_times.ToString();
  217. table.Cell(5, 1).Range.Text = "科室:";
  218. table.Cell(5, 2).Range.Text = "--";
  219. table.Cell(5, 3).Range.Text = "病床号:";
  220. table.Cell(5, 4).Range.Text = "----";
  221. table.Cell(5, 5).Range.Text = "单胎/多胎:";
  222. table.Cell(5, 6).Range.Text = "--";
  223. table.Cell(6, 1).Range.Text = "病区:";
  224. table.Cell(6, 2).Range.Text = "--";
  225. table.Cell(6, 3).Range.Text = "住院号:";
  226. table.Cell(6, 4).Range.Text = "--";
  227. table.Cell(6, 5).Range.Text = "设备型号:";
  228. table.Cell(6, 6).Range.Text = "HC2180-D";
  229. Microsoft.Office.Interop.Word.Paragraph oPara1 = WordDoc.Content.Paragraphs.Add(ref oMissing);
  230. oPara1.Range.Text = "____________________________________________________________________________________________";
  231. oPara1.Range.Font.Bold = 0;
  232. oPara1.Range.InsertParagraphAfter();
  233. //分栏测试
  234. //参数检测部分
  235. /*
  236. oPara1.Range.Text = "血液动力学参数检测";
  237. oPara1.Range.Font.Bold = 0;
  238. oPara1.Format.SpaceAfter = space;
  239. oPara1.Range.InsertParagraphAfter();
  240. */
  241. //插入表格
  242. //WordDoc.Content.InsertAfter("\n");
  243. WordApp.Selection.EndKey(ref unite, ref oMissing);
  244. //WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
  245. //WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
  246. int tableRow2 = 43;
  247. int tableColumn2 = 5;
  248. //定义一个word中的表格对象
  249. MSWord.Table table2 = WordDoc.Tables.Add(WordApp.Selection.Range, tableRow2, tableColumn2, ref oMissing, ref oMissing);
  250. table2.Range.Font.Size = 8;
  251. table2.Range.Font.Bold = 0;
  252. table2.Range.Rows.Height = 13;
  253. table2.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightExactly;
  254. table2.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft;
  255. //内线
  256. //table2.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
  257. table2.Columns[1].Width = 95;
  258. table2.Columns[2].Width = 40;
  259. table2.Columns[3].Width = 15;
  260. table2.Columns[4].Width = 95;
  261. table2.Columns[5].Width = 250;
  262. //table2.Columns[6].Width = 40;
  263. //table2.Columns[7].Width = 15;
  264. //table2.Columns[8].Width = 95;
  265. /*for(int i=1;i<=22;i++)
  266. {
  267. table2.Rows[i].Height = 60;
  268. }*/
  269. //合并表格
  270. table2.Cell(1, 1).Merge(table2.Cell(1, 4));
  271. table2.Cell(2, 5).Merge(table2.Cell(43, 5));
  272. //表格文字
  273. table2.Cell(1, 1).Range.Text = "血液动力学参数检测结果";
  274. table2.Cell(2, 1).Range.Text = "收缩压SPB:";
  275. table2.Cell(2, 2).Range.Text = rpRecord.shousuoya.ToString();
  276. try
  277. {
  278. double hbp = rpRecord.shousuoya;
  279. if (hbp > 130)
  280. {
  281. table2.Cell(2, 3).Range.Text = "↑";
  282. }
  283. else if (hbp < 90)
  284. {
  285. table2.Cell(2, 3).Range.Text = "↓";
  286. }
  287. else
  288. {
  289. }
  290. }
  291. catch (Exception)
  292. {
  293. }
  294. table2.Cell(2, 4).Range.Text = "90-130mmHg";
  295. table2.Cell(3, 1).Range.Text = "舒张压DPB:";
  296. table2.Cell(3, 2).Range.Text = rpRecord.shuzhangya.ToString();
  297. try
  298. {
  299. double hbp = rpRecord.shuzhangya;
  300. if (hbp > 100)
  301. {
  302. table2.Cell(3, 3).Range.Text = "↑";
  303. }
  304. else if (hbp < 60)
  305. {
  306. table2.Cell(3, 3).Range.Text = "↓";
  307. }
  308. else
  309. {
  310. }
  311. }
  312. catch (Exception)
  313. {
  314. }
  315. table2.Cell(3, 4).Range.Text = "60-100mmHg";
  316. table2.Cell(4, 1).Range.Text = "脉压PP:";
  317. table2.Cell(4, 2).Range.Text = rpRecord.maiya.ToString();
  318. if(rpRecord.maiya > 50)
  319. {
  320. table2.Cell(4, 3).Range.Text = "↑";
  321. }
  322. else if(rpRecord.maiya < 35)
  323. {
  324. table2.Cell(4, 3).Range.Text = "↓";
  325. }
  326. table2.Cell(4, 4).Range.Text = "35-50mmHg";
  327. table2.Cell(5, 1).Range.Text = "平均动脉压MAP:";
  328. table2.Cell(5, 2).Range.Text = rpRecord.pingjundongmaiya.ToString();
  329. try
  330. {
  331. double hbp = rpRecord.pingjundongmaiya;
  332. if (hbp > 95)
  333. {
  334. table2.Cell(5, 3).Range.Text = "↑";
  335. }
  336. else if (hbp < 85)
  337. {
  338. table2.Cell(5, 3).Range.Text = "↓";
  339. }
  340. else
  341. {
  342. }
  343. }
  344. catch (Exception)
  345. {
  346. }
  347. table2.Cell(5, 4).Range.Text = "85-95mmHg";
  348. table2.Cell(6, 1).Range.Text = "血压指数BPI:";
  349. table2.Cell(6, 2).Range.Text = rpRecord.xueyazhishu.ToString();
  350. try
  351. {
  352. double hbp = rpRecord.xueyazhishu;
  353. if (hbp > 150)
  354. {
  355. table2.Cell(6, 3).Range.Text = "↓";
  356. }
  357. else
  358. {
  359. }
  360. }
  361. catch (Exception)
  362. {
  363. }
  364. table2.Cell(6, 4).Range.Text = "<150";
  365. table2.Cell(7, 1).Range.Text = "体表面积TBA:";
  366. table2.Cell(7, 2).Range.Text = rpRecord.tibiaomianji.ToString();
  367. table2.Cell(7, 4).Range.Text = "m*m";
  368. table2.Cell(8, 1).Range.Text = "血总容量BV:"; //textBoxRPzongxuerongliangHistory
  369. table2.Cell(8, 2).Range.Text = rpRecord.zongxuerongliang.ToString();
  370. table2.Cell(8, 4).Range.Text = "(参考范围)";
  371. table2.Cell(9, 1).Range.Text = "波形系数K:";
  372. table2.Cell(9, 2).Range.Text = rpRecord.boxinxishu.ToString();
  373. try
  374. {
  375. double hbp = rpRecord.boxinxishu;
  376. if (hbp > 0.4)
  377. {
  378. table2.Cell(9, 3).Range.Text = "↑";
  379. }
  380. else if (hbp < 0.33)
  381. {
  382. table2.Cell(9, 3).Range.Text = "↓";
  383. }
  384. else
  385. {
  386. }
  387. }
  388. catch (Exception)
  389. {
  390. }
  391. table2.Cell(9, 4).Range.Text = "0.33-0.4";
  392. table2.Cell(10, 1).Range.Text = "体重指数WI:";
  393. table2.Cell(10, 2).Range.Text = rpRecord.tizhongzhishu.ToString();
  394. try
  395. {
  396. double hbp = rpRecord.tizhongzhishu;
  397. if (hbp > 0.24)
  398. {
  399. table2.Cell(10, 3).Range.Text = "↑";
  400. }
  401. else
  402. {
  403. }
  404. }
  405. catch (Exception)
  406. {
  407. }
  408. table2.Cell(10, 4).Range.Text = "<0.24";
  409. table2.Cell(11, 1).Range.Text = "心输出量CO:";
  410. table2.Cell(11, 2).Range.Text = rpRecord.xinshuchuliang.ToString();
  411. try
  412. {
  413. double hbp = rpRecord.xinshuchuliang;
  414. if (hbp > 7)
  415. {
  416. table2.Cell(11, 3).Range.Text = "↑";
  417. }
  418. else if (hbp < 3)
  419. {
  420. table2.Cell(11, 3).Range.Text = "↓";
  421. }
  422. else
  423. {
  424. }
  425. }
  426. catch (Exception)
  427. {
  428. }
  429. table2.Cell(11, 4).Range.Text = "3-7L/min";
  430. table2.Cell(12, 1).Range.Text = "外周阻力TPR:";
  431. table2.Cell(12, 2).Range.Text = rpRecord.waizhouzuli.ToString();
  432. try
  433. {
  434. double hbp = rpRecord.waizhouzuli;
  435. if (hbp > 1.4)
  436. {
  437. table2.Cell(12, 3).Range.Text = "↑";
  438. }
  439. else if (hbp < 0.9)
  440. {
  441. table2.Cell(12, 3).Range.Text = "↓";
  442. }
  443. else
  444. {
  445. }
  446. }
  447. catch (Exception)
  448. {
  449. }
  450. table2.Cell(12, 4).Range.Text = "0.9-1.4PRU";
  451. table2.Cell(13, 1).Range.Text = "每搏量SV:";
  452. table2.Cell(13, 2).Range.Text = rpRecord.meiboliang.ToString();
  453. try
  454. {
  455. double hbp = rpRecord.meiboliang;
  456. if (hbp > 100)
  457. {
  458. table2.Cell(13, 3).Range.Text = "↑";
  459. }
  460. else if (hbp < 60)
  461. {
  462. table2.Cell(13, 3).Range.Text = "↓";
  463. }
  464. else
  465. {
  466. }
  467. }
  468. catch (Exception)
  469. {
  470. }
  471. table2.Cell(13, 4).Range.Text = "60-100ml";
  472. table2.Cell(14, 1).Range.Text = "心脏指数CI:";
  473. table2.Cell(14, 2).Range.Text = rpRecord.xinzangzhishu.ToString();
  474. try
  475. {
  476. double hbp = rpRecord.xinzangzhishu;
  477. if (hbp > 4)
  478. {
  479. table2.Cell(14, 3).Range.Text = "↑";
  480. }
  481. else if (hbp < 2.5)
  482. {
  483. table2.Cell(14, 3).Range.Text = "↓";
  484. }
  485. else
  486. {
  487. }
  488. }
  489. catch (Exception)
  490. {
  491. }
  492. table2.Cell(14, 4).Range.Text = "2.5-4";
  493. table2.Cell(15, 1).Range.Text = "心搏指数SI:";
  494. table2.Cell(15, 2).Range.Text = rpRecord.xinbozhishu.ToString();
  495. try
  496. {
  497. double hbp = rpRecord.xinbozhishu;
  498. if (hbp > 60)
  499. {
  500. table2.Cell(15, 3).Range.Text = "↑";
  501. }
  502. else if (hbp < 40)
  503. {
  504. table2.Cell(15, 3).Range.Text = "↓";
  505. }
  506. else
  507. {
  508. }
  509. }
  510. catch (Exception)
  511. {
  512. }
  513. table2.Cell(15, 4).Range.Text = "40-60ml/m*m";
  514. table2.Cell(16, 1).Range.Text = "顺应性AC:";
  515. table2.Cell(16, 2).Range.Text = rpRecord.shunyinxing.ToString();
  516. try
  517. {
  518. double hbp = rpRecord.shunyinxing;
  519. if (hbp > 2)
  520. {
  521. table2.Cell(16, 3).Range.Text = "↑";
  522. }
  523. else if (hbp < 1.2)
  524. {
  525. table2.Cell(16, 3).Range.Text = "↓";
  526. }
  527. else
  528. {
  529. }
  530. }
  531. catch (Exception)
  532. {
  533. }
  534. table2.Cell(16, 4).Range.Text = "1.2-2ml/mmHg";
  535. table2.Cell(17, 1).Range.Text = "心率HR:";
  536. table2.Cell(17, 2).Range.Text = "";
  537. table2.Cell(17, 4).Range.Text = "bpm";
  538. table2.Cell(18, 1).Range.Text = "中心血流量CBF:";
  539. table2.Cell(18, 2).Range.Text = rpRecord.zhongxinxueliuliang.ToString();
  540. table2.Cell(19, 1).Range.Text = "血液黏度V:";
  541. table2.Cell(19, 2).Range.Text = rpRecord.xueyeniandu.ToString();
  542. try
  543. {
  544. double hbp = rpRecord.xueyeniandu;
  545. if (hbp > 4.5)
  546. {
  547. table2.Cell(19, 3).Range.Text = "↑";
  548. }
  549. else if (hbp < 3.8)
  550. {
  551. table2.Cell(16, 3).Range.Text = "↓";
  552. }
  553. else
  554. {
  555. }
  556. }
  557. catch (Exception)
  558. {
  559. }
  560. table2.Cell(19, 4).Range.Text = "3.8-4.5CP";
  561. table2.Cell(20, 1).Range.Text = "平均滞留时间T:";
  562. table2.Cell(20, 2).Range.Text = rpRecord.pingjunzhiliushijian.ToString();
  563. try
  564. {
  565. double hbp = rpRecord.pingjunzhiliushijian;
  566. if (hbp > 33)
  567. {
  568. table2.Cell(20, 3).Range.Text = "↑";
  569. }
  570. else if (hbp < 20)
  571. {
  572. table2.Cell(20, 3).Range.Text = "↓";
  573. }
  574. else
  575. {
  576. }
  577. }
  578. catch (Exception)
  579. {
  580. }
  581. table2.Cell(20, 4).Range.Text = "20-33s";
  582. //21项开始自动生成
  583. int startIdx = 21;
  584. /*
  585. for (int i = 0; i < expressions.Count && i + startIdx < 41; ++i)
  586. {
  587. SQLite.Expression oneExpression = SQLite.SQLiteModel.getExpressionByContent(expressions.ElementAt(i).Key);
  588. table2.Cell(i + startIdx, 1).Range.Text = oneExpression.expression_description;
  589. if (expressions.ElementAt(i).Value == Double.MinValue)
  590. {
  591. table2.Cell(i + startIdx, 2).Range.Text = "--";
  592. continue;
  593. }
  594. table2.Cell(i + startIdx, 2).Range.Text = expressions.ElementAt(i).Value.ToString();
  595. if (expressions.ElementAt(i).Value > oneExpression.upBound)
  596. {
  597. table2.Cell(i + startIdx, 3).Range.Text = "↑";
  598. }
  599. else if (expressions.ElementAt(i).Value < (oneExpression.upBound))
  600. {
  601. table2.Cell(i + startIdx, 3).Range.Text = "↓";
  602. }
  603. table2.Cell(i + startIdx, 4).Range.Text = oneExpression.downBound.ToString() + "-" + oneExpression.upBound.ToString();
  604. }*/
  605. //诊断部分
  606. string pailiangRemark = "";
  607. string zuliRemark = "";
  608. if (rpRecord.xpl < 4)
  609. {
  610. pailiangRemark = "低排";
  611. }
  612. else if(rpRecord.xpl > 5)
  613. {
  614. pailiangRemark = "高排";
  615. }
  616. else
  617. {
  618. pailiangRemark = "中排";
  619. }
  620. if (rpRecord.wzzl < 4)
  621. {
  622. zuliRemark = "低阻";
  623. }
  624. else if (rpRecord.wzzl > 5)
  625. {
  626. zuliRemark = "高阻";
  627. }
  628. else
  629. {
  630. zuliRemark = "中阻";
  631. }
  632. table2.Cell(2, 5).Range.Text = "自动分析结果:\n"
  633. + "一、参考结果\n"
  634. + rpRecord.cankaojieguo + "\n"
  635. + "二、参考指数\n"
  636. + "排量:" + rpRecord.xpl.ToString() + "(" + pailiangRemark + ")\n阻力:" + rpRecord.wzzl.ToString() + "(" + zuliRemark + ")\n"
  637. + "三、脉搏波形\n" + rcd.r_type + "\n"
  638. + "四、医师建议" + "\n风险等级:" + generalExpressionResult + "\n";// + mw.textBoxDiagnosis.Text;
  639. table2.Cell(2, 5).Range.Font.Size = 15;
  640. //自动分析结果
  641. /*
  642. oPara1.Range.Text = "______________________________________________________________________________________________________________";
  643. oPara1.Range.Font.Bold = fontBold;
  644. oPara1.Range.InsertParagraphAfter();
  645. */
  646. //插入分页符
  647. object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
  648. WordApp.Selection.EndKey(ref unite, ref oMissing);
  649. WordDoc.ActiveWindow.Selection.InsertBreak(ref oPageBreak);
  650. //图片页
  651. //图片1
  652. WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
  653. oPara1.Range.Text = "\n桡动脉波形图:";
  654. oPara1.Range.Font.Bold = 0;
  655. oPara1.Range.Font.Size = 15;
  656. oPara1.Format.SpaceAfter = space;
  657. oPara1.Range.InsertParagraphAfter();
  658. //插图
  659. WordApp.Selection.EndKey(ref unite, ref oMissing);
  660. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  661. string picture1 = Constants.tmpRPWave;
  662. //定义要向文档中插入图片的位置
  663. object range = WordDoc.Paragraphs.Last.Range;
  664. //定义该图片是否为外部链接
  665. object linkToFile = false;//默认
  666. //定义插入的图片是否随word一起保存
  667. object saveWithDocument = true;
  668. //向word中写入图片
  669. try
  670. {
  671. WordDoc.InlineShapes.AddPicture(picture1, ref oMissing, ref oMissing, ref oMissing);
  672. }
  673. catch (Exception)
  674. {
  675. Console.WriteLine("fail to load raodongmai.");
  676. }
  677. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  678. WordDoc.InlineShapes[1].Height = 130;
  679. WordDoc.InlineShapes[1].Width = 490;
  680. //WordDoc.Content.InsertAfter("\n");
  681. WordApp.Selection.EndKey(ref unite, ref oMissing);
  682. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  683. WordApp.Selection.Font.Size = 10;//字体大小
  684. WordApp.Selection.TypeText("右侧桡动脉\n");
  685. WordApp.Selection.EndKey(ref unite, ref oMissing);
  686. oPara1.Range.Text = "____________________________________________________________________________________________";
  687. oPara1.Range.Font.Bold = 0;
  688. oPara1.Range.Font.Size = 10;
  689. oPara1.Range.InsertParagraphAfter();
  690. //图片2.3
  691. WordApp.Selection.EndKey(ref unite, ref oMissing);
  692. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
  693. WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
  694. oPara1.Range.Text = cfg.report_figure_name + ":";
  695. oPara1.Range.Font.Bold = 0;
  696. oPara1.Range.Font.Size = 15;
  697. oPara1.Format.SpaceAfter = space;
  698. oPara1.Format.SpaceBefore = 0;
  699. oPara1.Range.InsertParagraphAfter();
  700. //插图
  701. WordApp.Selection.EndKey(ref unite, ref oMissing);
  702. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  703. string picture2 = Constants.tmpPPGLeftInfraredWave;
  704. string picture3 = Constants.tmpPPGLeftRedWave;
  705. string picture4 = Constants.tmpPPGRightRedWave;
  706. string picture5 = Constants.tmpPPGRightInfraredWave;
  707. //向word中写入图片
  708. try
  709. {
  710. WordDoc.InlineShapes.AddPicture(picture2, ref oMissing, ref oMissing, ref oMissing);
  711. WordDoc.InlineShapes.AddPicture(picture3, ref oMissing, ref oMissing, ref oMissing);
  712. WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
  713. WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
  714. }
  715. catch (Exception)
  716. {
  717. Console.WriteLine("fail to load a image.");
  718. }
  719. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  720. for(int i = 2; i < 6; ++i)
  721. {
  722. WordDoc.InlineShapes[i].Height = 80;
  723. WordDoc.InlineShapes[i].Width = 200;
  724. }
  725. //WordDoc.Content.InsertAfter("\n");
  726. WordApp.Selection.EndKey(ref unite, ref oMissing);
  727. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  728. WordApp.Selection.Font.Size = 10;//字体大小
  729. WordApp.Selection.TypeText("左手手指 红外光\n");
  730. //左手红光
  731. WordApp.Selection.EndKey(ref unite, ref oMissing);
  732. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  733. /*
  734. try
  735. {
  736. WordDoc.InlineShapes.AddPicture(picture3, ref oMissing, ref oMissing, ref oMissing);
  737. }
  738. catch (Exception)
  739. {
  740. Console.WriteLine("fail to load ppg Left2.");
  741. }
  742. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  743. WordDoc.InlineShapes[3].Height = 100;
  744. WordDoc.InlineShapes[3].Width = 245;
  745. //WordDoc.Content.InsertAfter("\n");
  746. WordApp.Selection.EndKey(ref unite, ref oMissing);
  747. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  748. WordApp.Selection.Font.Size = 10;//字体大小
  749. WordApp.Selection.TypeText("左手手指 红光\n");
  750. //右手红外光
  751. WordApp.Selection.EndKey(ref unite, ref oMissing);
  752. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  753. //向word中写入图片
  754. try
  755. {
  756. WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
  757. }
  758. catch (Exception)
  759. {
  760. Console.WriteLine("fail to load ppg right1.");
  761. }
  762. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  763. WordDoc.InlineShapes[4].Height = 130;
  764. WordDoc.InlineShapes[4].Width = 490;
  765. //WordDoc.Content.InsertAfter("\n");
  766. WordApp.Selection.EndKey(ref unite, ref oMissing);
  767. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  768. WordApp.Selection.Font.Size = 10;//字体大小
  769. WordApp.Selection.TypeText("右手手指 红外光\n");
  770. //右手红外光
  771. WordApp.Selection.EndKey(ref unite, ref oMissing);
  772. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  773. //向word中写入图片
  774. try
  775. {
  776. WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
  777. }
  778. catch (Exception)
  779. {
  780. Console.WriteLine("fail to load ppg right1.");
  781. }
  782. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  783. WordDoc.InlineShapes[5].Height = 130;
  784. WordDoc.InlineShapes[5].Width = 490;
  785. //WordDoc.Content.InsertAfter("\n");
  786. WordApp.Selection.EndKey(ref unite, ref oMissing);
  787. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  788. WordApp.Selection.Font.Size = 10;//字体大小
  789. WordApp.Selection.TypeText("右手手指 红光\n");
  790. */
  791. //插入分页符
  792. //object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
  793. //WordApp.Selection.EndKey(ref unite, ref oMissing);
  794. // WordDoc.ActiveWindow.Selection.InsertBreak(ref oPageBreak);
  795. //第三页
  796. /*
  797. WordApp.Selection.EndKey(ref unite, ref oMissing);
  798. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
  799. WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
  800. oPara1.Range.Text = "趋势图:";
  801. oPara1.Range.Font.Bold = 0;
  802. oPara1.Range.Font.Size = 15;
  803. oPara1.Format.SpaceBefore = space;
  804. oPara1.Format.SpaceAfter = space;
  805. oPara1.Range.InsertParagraphAfter();
  806. //插图
  807. WordApp.Selection.EndKey(ref unite, ref oMissing);
  808. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  809. string picture4 = "c:\\picture\\raodongmai.png";
  810. //定义要向文档中插入图片的位置
  811. //向word中写入图片
  812. WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
  813. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  814. WordDoc.InlineShapes[4].Height = 130;
  815. WordDoc.InlineShapes[4].Width = 490;
  816. //WordDoc.Content.InsertAfter("\n");
  817. WordApp.Selection.EndKey(ref unite, ref oMissing);
  818. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  819. WordApp.Selection.Font.Size = 10;//字体大小
  820. WordApp.Selection.TypeText("IPR 右侧桡动脉\n");
  821. WordApp.Selection.EndKey(ref unite, ref oMissing);
  822. oPara1.Range.Text = "________________________________________________________________________________________________________________";
  823. oPara1.Range.Font.Bold = 0;
  824. oPara1.Range.Font.Size = 10;
  825. oPara1.Format.SpaceAfter = 0;
  826. oPara1.Range.InsertParagraphAfter();
  827. //图片2.3
  828. WordApp.Selection.EndKey(ref unite, ref oMissing);
  829. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
  830. WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
  831. oPara1.Range.Text = "趋势图:";
  832. oPara1.Range.Font.Bold = 0;
  833. oPara1.Range.Font.Size = 15;
  834. oPara1.Format.SpaceAfter = space;
  835. oPara1.Range.InsertParagraphAfter();
  836. //插图
  837. WordApp.Selection.EndKey(ref unite, ref oMissing);
  838. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  839. string picture5 = "c:\\picture\\2.png";
  840. //向word中写入图片
  841. WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
  842. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  843. WordDoc.InlineShapes[5].Height = 130;
  844. WordDoc.InlineShapes[5].Width = 490;
  845. //WordDoc.Content.InsertAfter("\n");
  846. WordApp.Selection.EndKey(ref unite, ref oMissing);
  847. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  848. WordApp.Selection.Font.Size = 10;//字体大小
  849. WordApp.Selection.TypeText("RI 左手手指 红外光\n");
  850. WordApp.Selection.EndKey(ref unite, ref oMissing);
  851. WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
  852. string picture6 = "c:\\picture\\3.png";
  853. //向word中写入图片
  854. WordDoc.InlineShapes.AddPicture(picture6, ref oMissing, ref oMissing, ref oMissing);
  855. WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
  856. WordDoc.InlineShapes[6].Height = 130;
  857. WordDoc.InlineShapes[6].Width = 490;
  858. //WordDoc.Content.InsertAfter("\n");
  859. WordApp.Selection.EndKey(ref unite, ref oMissing);
  860. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
  861. WordApp.Selection.Font.Size = 10;//字体大小
  862. WordApp.Selection.TypeText("RI 右手手指 红外光\n");
  863. WordApp.Selection.EndKey(ref unite, ref oMissing);
  864. //*/
  865. oPara1.Range.Text = "____________________________________________________________________________________________";
  866. oPara1.Range.Font.Bold = 0;
  867. oPara1.Range.Font.Size = 10;
  868. oPara1.Format.SpaceBefore = 0;
  869. oPara1.Format.SpaceAfter = 0;
  870. oPara1.Range.InsertParagraphAfter();
  871. //医师签名
  872. WordApp.Selection.EndKey(ref unite, ref oMissing);
  873. WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
  874. WordApp.Selection.ParagraphFormat.FirstLineIndent = 150;
  875. oPara1.Range.Text = "检查医师:" + doct.name + " 医师签名:";
  876. oPara1.Range.Font.Bold = 0;
  877. oPara1.Range.Font.Size = 15;
  878. oPara1.Format.SpaceAfter = 0;
  879. oPara1.Format.SpaceBefore = 0;
  880. oPara1.Range.InsertParagraphAfter();
  881. // object LinkToFile = false;
  882. object SaveWithDocument = true;
  883. // object Anchor = WordDoc.Application.Selection.Range;
  884. /*
  885. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
  886. WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName4, ref LinkToFile, ref SaveWithDocument, ref Anchor);
  887. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
  888. WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName3, ref LinkToFile, ref SaveWithDocument, ref Anchor);
  889. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
  890. WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName2, ref LinkToFile, ref SaveWithDocument, ref Anchor);
  891. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
  892. WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName1, ref LinkToFile, ref SaveWithDocument, ref Anchor);
  893. WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
  894. WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName0, ref LinkToFile, ref SaveWithDocument, ref Anchor);
  895. */
  896. //保存
  897. WordDoc.Save();
  898. WordDoc.ExportAsFixedFormat(pdfFileName, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, true);
  899. }
  900. catch (Exception e)
  901. {
  902. Console.WriteLine(e.Message);
  903. Console.WriteLine(e.StackTrace);
  904. }
  905. finally
  906. {
  907. //try
  908. //{
  909. WordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
  910. WordApp.Quit(ref oMissing, ref oMissing, ref oMissing);
  911. //}
  912. //catch (Exception)
  913. //{
  914. //}
  915. try
  916. {
  917. File.Delete(fileName);
  918. }
  919. catch (Exception)
  920. {
  921. ;
  922. }
  923. }
  924. }
  925. }
  926. }