//Title: 个人健康管理分析报告
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.Windows.Forms;
using System.Data;
using HMSClientServiceFactory.BASE.HMS;
using Microsoft.Office.Interop.Word;
using PdfiumViewer;
using Syscom.Comm.Utility;
using System.IO;
using System.Drawing;
using HMSClientServiceFactory.BASE.PUB;
using System.Drawing.Imaging; namespace Syscom.HMS.Client.HMS.RPT
{
public class HmsRpt1070Client
{
IPubServiceManager PUBSM = new PubServiceManager();
#region 报告打印
Word.Application WordApp = new Word.Application();
Word.Document WordDoc = new Word.Document();
HmsServiceManager hmsService = new HmsServiceManager(); object Nothing = System.Reflection.Missing.Value;
private string strMemberNo;
int TableCount = ;
/// <summary>
/// 打印报告
/// </summary>
/// <param name="strRegisterNo">体检号</param>
public HmsRpt1070Client(string strMemberNo, DataTable dtItem)
{
try
{
this.strMemberNo = strMemberNo;
DataSet dsHms = new DataSet(); dsHms = hmsService.QueryDataSetBy1070(strMemberNo);
System.Data.DataTable dtPatient = new System.Data.DataTable();
//查询客户信息
dtPatient = dsHms.Tables["HMS_MEMBER"];
//不同身份调用不同模板
string filename = System.Windows.Forms.Application.StartupPath + "\\RPT\\HMSRPT1070.dot";
try
{
WordDoc = WordApp.Documents.Add(filename);
WordDoc = WordApp.ActiveDocument;
}
catch (Exception ex)
{
throw (ex);
}
if (dtPatient.Rows.Count > )
{
#region 模板页签中插入数据
//个人信息
WordDoc.Bookmarks.get_Item("Name").Range.Text = dtPatient.Rows[]["PATIENT_NAME"].ToString();
WordDoc.Bookmarks.get_Item("Gender").Range.Text = dtPatient.Rows[]["SEX"].ToString();
WordDoc.Bookmarks.get_Item("Birthday").Range.Text = dtPatient.Rows[]["BIRTHDAY"].ToString();
WordDoc.Bookmarks.get_Item("Age").Range.Text = dtPatient.Rows[]["AGE"].ToString(); WordDoc.Bookmarks.get_Item("Tel").Range.Text = dtPatient.Rows[]["PHONE_NO"].ToString();
WordDoc.Bookmarks.get_Item("NurseName").Range.Text = dtPatient.Rows[]["NURSE_NAME"].ToString();
WordDoc.Bookmarks.get_Item("Date").Range.Text = DateTime.Now.ToString("yyyy-MM-dd"); WordDoc.Bookmarks.get_Item("PATIENT_NAME").Range.Text = dtPatient.Rows[]["PATIENT_NAME"].ToString() + (dtPatient.Rows[]["PATIENT_SEX"].ToString().Trim() == "" ? "先生" : "女士") + ":"; #endregion
if (dtItem.Rows.Count > )
{
for (int n = ; n < dtItem.Rows.Count - ; n++)
{
CopyTable();
}
DataTable dtHmsReportMemo = new DataTable("HMS_REPORT_MEMO");
dtHmsReportMemo = dsHms.Tables["HMS_REPORT_MEMO"]; DataTable dtMemberReport = new DataTable("HMS_MEMBER_REPORT");
dtMemberReport = dsHms.Tables["HMS_MEMBER_REPORT"]; DataTable dtMemberRecipe = new DataTable("HMS_MEMBER_RECIPE");
dtMemberRecipe = dsHms.Tables["HMS_MEMBER_RECIPE"]; for (int i = ; i < dtItem.Rows.Count; i++)
{
WordDoc.Tables[TableCount].Cell(, ).Width = WordDoc.Tables[TableCount].Cell(, ).Width - ;
WordDoc.Tables[TableCount].Cell(, ).Range.Text = dtItem.Rows[i]["SYS_CODE_NAME"].ToString();
WordDoc.Tables[TableCount].Cell(, ).Range.Font.Color = WdColor.wdColorBlack;
WordDoc.Tables[TableCount].Cell(, ).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
WordDoc.Tables[TableCount].Cell(, ).Range.Font.Bold = ;
WordDoc.Tables[TableCount].Cell(, ).Range.Font.Size = ; int iNewRow = ;
int iCol = ; if (dtHmsReportMemo.Rows.Count > )
{
DataRow[] dr = dtHmsReportMemo.Select("REPORT_ID = '" + dtItem.Rows[i]["SYS_CODE"].ToString().Trim() + "'");
if (dr.Length > )
{
WordDoc.Tables[TableCount].Cell(, ).Range.Text = dr[]["MEMO"].ToString(); if (dtMemberReport.Rows.Count > )
{
DataRow[] drMemberReport = dtMemberReport.Select("REPORT_ID = '" + dr[]["REPORT_ID"].ToString().Trim() + "'");
if (drMemberReport.Length > )
{
for (int j = ; j < drMemberReport.Length; j++)
{
if (j == )
{
WordDoc.Tables[TableCount].Rows[iNewRow].Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
WordDoc.Tables[TableCount].Rows[iNewRow].Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
WordDoc.Content.Tables[TableCount].Rows.Add(ref Nothing);
iNewRow += ; }
else
{
if (j % == )
{
WordDoc.Content.Tables[TableCount].Rows.Add(ref Nothing);
WordDoc.Content.Tables[TableCount].Rows.Add(ref Nothing);
iNewRow += ;
}
}
iCol = j % + ; WordDoc.Tables[TableCount].Cell(iNewRow - , iCol).Range.Text = drMemberReport[j]["REPORT_DATE"].ToString().Trim();
WordDoc.Tables[TableCount].Cell(iNewRow - , iCol).Range.Font.Bold = ;
WordDoc.Tables[TableCount].Rows[iNewRow - ].Range.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToWin32(Color.FromArgb(, , ));
WordDoc.Tables[TableCount].Cell(iNewRow - , iCol).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
WordDoc.Tables[TableCount].Cell(iNewRow - , iCol).Range.Font.Size = ; WordDoc.Tables[TableCount].Cell(iNewRow, iCol).Range.Text = drMemberReport[j]["REPORT_RESULT"].ToString().Trim();
WordDoc.Tables[TableCount].Cell(iNewRow, iCol).Range.Font.Bold = ;
WordDoc.Tables[TableCount].Cell(iNewRow, iCol).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
WordDoc.Tables[TableCount].Cell(iNewRow, iCol).Range.Shading.BackgroundPatternColor = WdColor.wdColorWhite;
WordDoc.Tables[TableCount].Cell(iNewRow, iCol).Range.Font.Size = ;
}
}
} WordDoc.Content.Tables[TableCount].Rows.Add(ref Nothing);
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Merge(WordDoc.Tables[TableCount].Cell(iNewRow + , ));
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Text = dr[]["SYS_CODE_NAME"].ToString();
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Color = WdColor.wdColorBlue;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Bold = ;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Size = ; WordDoc.Tables[TableCount].Cell(iNewRow + , ).Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Borders[WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleSingle; if (dtMemberRecipe.Rows.Count > )
{
DataRow[] drMemberRecipe = dtMemberRecipe.Select("RECIPE_TYPE = '" + dr[]["RECIPE_TYPE"].ToString().Trim() + "'");
if (drMemberRecipe.Length > )
{
WordDoc.Content.Tables[TableCount].Rows.Add(ref Nothing);
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Text = drMemberRecipe[]["RECIPE_CONTENT"].ToString();
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Color = WdColor.wdColorBlack;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Size = ;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Bold = ;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Borders[WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone; WordDoc.Content.Tables[TableCount].Rows.Add(ref Nothing);
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Text = drMemberRecipe[]["RECIPE_NAME"].ToString();
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Bold = ;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Range.Font.Color = WdColor.wdColorBlack;
}
}
else
{
WordDoc.Tables[TableCount].Cell(iNewRow + , ).Borders[WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone;
}
}
}
TableCount++;
}
}
#region 保存Word
SaveFileDialog sfd = new SaveFileDialog();
string strFileName = strMemberNo + "_" + DateTime.Now.ToString("yyyyMMddHHmmss");
sfd.FileName = strFileName + ".doc";
object oMissing = System.Reflection.Missing.Value;
object ofilename = sfd.FileName;
WordApp.Visible = true;
#endregion
WordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
WordDoc.Saved = true;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 复制模板
//复制模板
private void CopyTable()
{
try
{
WordDoc.Tables[].Select();
WordApp.Selection.Copy(); object mymessing = System.Reflection.Missing.Value;
object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
WordApp.Selection.EndKey(ref myunit, ref mymessing); object count = ;
object oMissing = System.Reflection.Missing.Value;
object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
WordApp.Selection.TypeParagraph();//插入段落 WordApp.Selection.Paste();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion }
}

插入书签,合并拆分Word 表格,插入图片,插入PDF,转换PDF

最新文章

  1. MongoDB 导出、导入表
  2. web安全——代理(nginx)
  3. 9.SpringMVC和json结合传递参数
  4. 省略文字的css
  5. IOS8 空项目全屏
  6. 利用css做扇形
  7. LeetCode Letter Combinations of a Phone Number 电话号码组合
  8. APP测试基本流程
  9. Linux下GPIO驱动(二) ----s3c_gpio_cfgpin();gpio_set_value();
  10. POJ 2299 Ultra-QuickSort 归并排序、二叉排序树,求逆序数
  11. a标签的伪元素的应用——link,hover,visited,active
  12. Jetty添加Filter过滤器
  13. 微信小程序页面跳转 的几种方式
  14. Android手机刘海屏(附工具类)
  15. Java8之分组
  16. Android进阶AIDL - 2018年4月14日
  17. js学习(初)
  18. 680. Valid Palindrome II
  19. Visual Studio 2017 百度云下载
  20. 说说CSS样式中你不知道的“大于号”

热门文章

  1. ResNet详解与分析
  2. Java工作流系统jflow从表功能介绍一
  3. 关系模式范式分解教程 3NF与BCNF口诀
  4. Django之F与Q查询
  5. Mac搭建本地服务器并映射到外网
  6. IDAE快捷键与设置
  7. .Net框架的模块代码生成器--其一(dotnet new)
  8. vue添加swiper的正确方式亲测---切图网
  9. 如何将文本放置在div的底部显示呢?
  10. Linux命令详解之–chmod命令