Esempio n. 1
0
        private void InsertFromSharePoint()
        {
            //Create a table
            Microsoft.Office.Interop.Word.Table tbl = GiveMeATable(1, 1,
                                                                   this.Application.ActiveDocument, this.Application.Selection.Range);

            //Add some table stylings
            tbl.ApplyStyleHeadingRows = true;
            tbl.ApplyStyleRowBands    = true;
            tbl.set_Style("Grid Table 4 - Accent 6");
            //Green. I like green.



            string siteUrl = Properties.Settings.Default.ClientContextUrl;

            using (var context = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, Properties.Settings.Default.ClientId, Properties.Settings.Default.ClientSecret))
            {
                context.Load(context.Web);
                context.ExecuteQuery();

                //We need a counter...
                int i = 1;
                //And a table header
                tbl.Cell(i, 1).Range.Text = "SharePoint Site Lists - " +
                                            context.Web.Title;

                //Requery to get the lists
                context.Load(context.Web.Lists);
                context.ExecuteQuery();
            }
        }
Esempio n. 2
0
 private Microsoft.Office.Interop.Word.Table GiveMeATable(
     int columnCount, int rowCount, Microsoft.Office.Interop.Word.Document doc, Microsoft.Office.Interop.Word.Range rg)
 {
     if (columnCount > 0 & rowCount > 0)
     {
         //We aren't goofing around. Let's make a table.
         Microsoft.Office.Interop.Word.Table tbl = default(Microsoft.Office.Interop.Word.Table);
         tbl = doc.Tables.Add(rg, rowCount, columnCount,
                              Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord9TableBehavior,
                              Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitContent);
         return(tbl);
     }
     return(null);
 }
Esempio n. 3
0
        public static Table getTable(Document doc, String title)
        {
            int totalTables = doc.Tables.Count;

            Microsoft.Office.Interop.Word.Table ret = null;
            for (int i = 1; i <= totalTables; i++)
            {
                if (title.Equals(doc.Tables[i].Title, StringComparison.OrdinalIgnoreCase))
                {
                    ret = doc.Tables[i];
                    break;
                }
            }

            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        /// //////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void GetNewReport(DataTable dt, string Score, string Knock, string strDep)
        {
            object oMissing = System.Reflection.Missing.Value;
            object unknow   = Type.Missing;

            object start = 0;
            object end   = 0;

            Microsoft.Office.Interop.Word.Range tableLocation = ActiveDocumentManager.getDefaultAD().Range(ref start, ref end);
            // 添加页眉
            emrtaskpane.wordApp.ActiveWindow.View.Type     = Word.WdViewType.wdOutlineView;
            emrtaskpane.wordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
            emrtaskpane.wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("");
            emrtaskpane.wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight; //设置右对齐
            emrtaskpane.wordApp.ActiveWindow.View.SeekView          = Word.WdSeekView.wdSeekMainDocument;              //跳出页眉设置

            emrtaskpane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;                                           //设置文档的行间距

            //移动焦点并换行
            object count  = 14;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;              //换一行;

            emrtaskpane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrtaskpane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点

            emrtaskpane.wordApp.Selection.TypeParagraph();                             //插入段落

            Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;

            range.Select();
            range.Text = "扣分情况明细表";
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 14.5f;
            range.Start     = range.End;
            range.Select();

            /////////Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrtaskpane.wordApp.Selection.Range, dt.Rows.Count+1, 9, ref unknow, ref unknow);
            Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrtaskpane.wordApp.Selection.Range, dt.Rows.Count + 1, 4, ref unknow, ref unknow);



            //设置表格样式
            newTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            newTable.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleSingle;
            emrtaskpane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距

            newTable.Cell(1, 1).Range.Text = "记录名称";
            newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 2).Range.Text = "扣分原因";
            newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 3).Range.Text = "扣分";
            newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 4).Range.Text = "记录得分";
            newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;


            newTable.Columns[1].Width = 80f;
            newTable.Columns[2].Width = 220f;
            newTable.Columns[3].Width = 35f;
            newTable.Columns[4].Width = 70f;


            decimal dLose    = 0;
            decimal GotScotr = 0;

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["NoteName"].ToString();
                    newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["LoseReason"].ToString();
                    newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["LoseScore"].ToString();
                    if (dt.Rows[i]["LoseScore"].ToString().Trim() != "")
                    {
                        dLose = dLose + Convert.ToDecimal(dt.Rows[i]["LoseScore"].ToString());
                    }
                    newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["Score"].ToString();
                    if (dt.Rows[i]["Score"].ToString().Trim() != "")
                    {
                        GotScotr = GotScotr + Convert.ToDecimal(dt.Rows[i]["Score"].ToString());
                    }
                    newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                }
            }

            // */



            object Line1 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;

            //object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
            emrtaskpane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点
            emrtaskpane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点

            emrtaskpane.wordApp.Selection.TypeParagraph();                            //插入段落



            Word.Range range1 = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range1.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;

            range1.Select();
            //range1.Text = "姓名:" + this.valuateText + this.selfValuate + this.scorePercent + "44" + this.panel1 + this.panel2 + "33" + this.lbPatient + "55" + this.lbValuate + "11" + this.count + "66" + this.components + "22" + this.btnReport + "等级:" + "得分:" + this.regID;
            string temp1, temp2, temp3, temp4;

            temp1 = this.lbPatient.ToString();
            temp2 = temp1.Substring(34);
            temp3 = this.lbValuate.ToString();
            temp4 = temp3.Substring(34);



            range1.Text = "科室:" + strDep + "  " + "患者姓名:" + temp2 + "  " + "得分:" + GotScotr.ToString() + "  " + "扣分:" + dLose.ToString() + "  " + "等级:" + temp4;

            range1.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            range1.Font.Name = "黑体";
            range1.Font.Size = 10f;
            range1.Start     = range.End;



            //Globals.ThisAddIn.HideEmrTaskPane();
            //Globals.ThisAddIn.ShowNoteMenu();
            //Globals.ThisAddIn.noteMenu.OperationEnableForStat(true);
        }
Esempio n. 5
0
        public void GetNewReport(DataTable dt)
        {
            object oMissing = System.Reflection.Missing.Value;
            object unknow   = Type.Missing;
            object start    = 0;
            object end      = 0;

            Microsoft.Office.Interop.Word.Range tableLocation = ActiveDocumentManager.getDefaultAD().Range(ref start, ref end);
            // 添加页眉
            emrTaskPane.wordApp.ActiveWindow.View.Type     = Word.WdViewType.wdOutlineView;
            emrTaskPane.wordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
            emrTaskPane.wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("");
            emrTaskPane.wordApp.Selection.ParagraphFormat.Alignment   = Word.WdParagraphAlignment.wdAlignParagraphRight; //设置右对齐
            emrTaskPane.wordApp.ActiveWindow.View.SeekView            = Word.WdSeekView.wdSeekMainDocument;              //跳出页眉设置
            emrTaskPane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;                                             //设置文档的行间距

            //2012-07-29 LiuQi 删除页眉
            int c = ActiveDocumentManager.getDefaultAD().Paragraphs[1].Borders.Count;

            emrTaskPane.wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader;
            Microsoft.Office.Interop.Word.Application WordApp;
            Microsoft.Office.Interop.Word.Document    WordDoc;
            WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
            if (c != 0)
            {
                Word.HeaderFooter hf = ActiveDocumentManager.getDefaultAD().Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary];
                Word.Range        r  = hf.Range;
                //r.Start = r.End;
                r.Select();
                Word.Border border = r.Borders[Word.WdBorderType.wdBorderBottom];
                border.Visible = false;
            }
            //移动焦点并换行
            object count  = 14;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;              //换一行;

            emrTaskPane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.TypeParagraph();                             //插入段落
            Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;

            range.Select();
            //// range.Text = "病历质量月度评分表" + "(" + comboBox2.Text + "年" + comboBox1.Text + "月)";
            if (hz)
            {
                range.Text = "各科室现岗病历质检情况一览表";
            }
            else
            {
                range.Text = "现岗病历质量评分科室汇总表";
            }
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 15.5f;
            range.Start     = range.End;
            range.Select();


            range.Text = dateTimePickerStart.Value.ToString() + "至" + dateTimePickerEnd.Value.ToString();
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 10f;
            range.Start     = range.End;
            range.Select();

            ActiveDocumentManager.getDefaultAD().PageSetup.Orientation = Word.WdOrientation.wdOrientPortrait;
            ActiveDocumentManager.getDefaultAD().PageSetup.PageWidth = emrTaskPane.wordApp.CentimetersToPoints(29.7F);
            ActiveDocumentManager.getDefaultAD().PageSetup.PageHeight = emrTaskPane.wordApp.CentimetersToPoints(21F);
            int rows = 0;

            if (ks || qy)
            {
                rows = 9;
            }
            else
            {
                rows = 8;
            }
            Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrTaskPane.wordApp.Selection.Range, dt.Rows.Count + 1, rows, ref unknow, ref unknow);
            //设置表格样式
            newTable.Range.Font.Size          = 11.0f;
            newTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            newTable.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleSingle;
            emrTaskPane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距
            if (ks || qy)
            {
                newTable.Cell(1, 1).Range.Text = "科室";
                newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 2).Range.Text = "主治医师";
                newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Cell(1, 3).Range.Text = "病案号";
                newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 4).Range.Text = "住院日期";
                newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Cell(1, 5).Range.Text = "住院号";
                newTable.Cell(1, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 6).Range.Text = "扣分项目";
                newTable.Cell(1, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 7).Range.Text = "扣分原因";
                newTable.Cell(1, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 8).Range.Text = "总得分";
                newTable.Cell(1, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 9).Range.Text = "等级";
                newTable.Cell(1, 9).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Columns[1].Width = 60f;
                newTable.Columns[2].Width = 60f;
                newTable.Columns[3].Width = 70f;//能显示三个字
                newTable.Columns[4].Width = 65f;
                newTable.Columns[5].Width = 60f;
                newTable.Columns[6].Width = 70f;
                newTable.Columns[7].Width = 220f;
                newTable.Columns[8].Width = 50f;
                newTable.Columns[9].Width = 40f;

                //if (dt.Rows.Count > 0)
                //{

                //    try
                //    {
                //        for (int i = 0; i < dt.Rows.Count; i++)
                //        {

                //            newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["zyrq"].ToString();
                //            newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["ksmc"].ToString();
                //            newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["ysm"].ToString();
                //            newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["bah"].ToString();
                //            newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["zyh"].ToString();
                //            newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;


                //            newTable.Cell(i + 2, 6).Range.Text = dt.Rows[i]["kfxm"].ToString();
                //            newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                //            newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["kfyy"].ToString();
                //            newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 8).Range.Text = dt.Rows[i]["sdf"].ToString();
                //            newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 9).Range.Text = dt.Rows[i]["pj"].ToString();
                //            newTable.Cell(i + 2, 9).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                //        }

                //        verticalCellMerge(newTable, 2, 1);
                //        verticalCellMerge(newTable, 2, 2);
                //        verticalCellMerge(newTable, 2, 3);
                //        verticalCellMerge(newTable, 2, 4);
                //        verticalCellMerge(newTable, 2, 8);
                //        verticalCellMerge(newTable, 2, 9);
                //        verticalCellMerge(newTable, 2, 5);
                //        // verticalCellMerge(newTable,2,5);
                //    }
                //    catch (Exception ex)
                //    {

                //        MessageBox.Show(ex.ToString());
                //    }
                //}
                if (dt.Rows.Count > 0)
                {
                    try
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["住院日期"].ToString();
                            newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                            newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["质检医师"].ToString();
                            newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["病案号"].ToString();
                            newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["住院号"].ToString();
                            newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;


                            newTable.Cell(i + 2, 6).Range.Text = dt.Rows[i]["扣分项目"].ToString();
                            newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                            newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["扣分原因"].ToString();
                            newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 8).Range.Text = dt.Rows[i]["总得分"].ToString();
                            newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 9).Range.Text = dt.Rows[i]["评审结果"].ToString();
                            newTable.Cell(i + 2, 9).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        }

                        verticalCellMerge(newTable, 2, 1);
                        verticalCellMerge(newTable, 2, 2);
                        verticalCellMerge(newTable, 2, 3);
                        verticalCellMerge(newTable, 2, 4);
                        verticalCellMerge(newTable, 2, 8);
                        verticalCellMerge(newTable, 2, 9);
                        verticalCellMerge(newTable, 2, 5);
                        // verticalCellMerge(newTable,2,5);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            else
            {
                newTable.Cell(1, 1).Range.Text = "科室";
                newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 2).Range.Text = "病历质检数";
                newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 3).Range.Text = "甲级";
                newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 4).Range.Text = "甲级病历率";
                newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 5).Range.Text = "乙级";
                newTable.Cell(1, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 6).Range.Text = "乙级病历率";
                newTable.Cell(1, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 7).Range.Text = "丙级";
                newTable.Cell(1, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 8).Range.Text = "丙级病历率";
                newTable.Cell(1, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Columns[1].Width = 70f;
                newTable.Columns[2].Width = 70f;
                newTable.Columns[3].Width = 70f;//能显示三个字
                newTable.Columns[4].Width = 70f;
                newTable.Columns[5].Width = 70f;
                newTable.Columns[6].Width = 70f;

                if (dt.Rows.Count > 0)
                {
                    int k = 2;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        decimal bl    = Convert.ToDecimal(dt.Rows[i]["病历率"].ToString());
                        string  strbl = (Convert.ToDecimal(bl.ToString("0.00")) * 100).ToString() + "%";

                        if (i > 0)
                        {
                            if (dt.Rows[i]["科室"].ToString() == dt.Rows[i - 1]["科室"].ToString())
                            {
                                newTable.Cell(k, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                                newTable.Cell(k, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(k, 2).Range.Text = dt.Rows[i]["科室质检数"].ToString();
                                newTable.Cell(k, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                                if (dt.Rows[i]["评级"].ToString() == "甲")
                                {
                                    newTable.Cell(k, 3).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 4).Range.Text = strbl;
                                    newTable.Cell(k, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "乙")
                                {
                                    newTable.Cell(k, 5).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 6).Range.Text = strbl;
                                    newTable.Cell(k, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "丙")
                                {
                                    newTable.Cell(k, 7).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 8).Range.Text = strbl;
                                    newTable.Cell(k, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                            }
                            else
                            {
                                k++;
                                newTable.Cell(k, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                                newTable.Cell(k, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(k, 2).Range.Text = dt.Rows[i]["科室质检数"].ToString();;
                                newTable.Cell(k, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                                if (dt.Rows[i]["评级"].ToString() == "甲")
                                {
                                    newTable.Cell(k, 3).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 4).Range.Text = strbl;
                                    newTable.Cell(k, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "乙")
                                {
                                    newTable.Cell(k, 5).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 6).Range.Text = strbl;
                                    newTable.Cell(k, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "丙")
                                {
                                    newTable.Cell(k, 7).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 8).Range.Text = strbl;
                                    newTable.Cell(k, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                            }
                        }
                        else
                        {
                            newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                            newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["科室质检数"].ToString();
                            newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                            if (dt.Rows[i]["评级"].ToString() == "甲")
                            {
                                newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["病历数"].ToString();
                                newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(i + 2, 4).Range.Text = strbl;
                                newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                            else if (dt.Rows[i]["评级"].ToString() == "乙")
                            {
                                newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["病历数"].ToString();
                                newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(i + 2, 6).Range.Text = strbl;
                                newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                            else if (dt.Rows[i]["评级"].ToString() == "丙")
                            {
                                newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["病历数"].ToString();
                                newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(i + 2, 8).Range.Text = strbl;
                                newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                        }
                    }
                    //删除多余的行
                    for (int i = 2; i <= newTable.Rows.Count; i++)
                    {
                        if (newTable.Cell(i, 1).Range.Text == "\r\a")
                        {
                            newTable.Rows[i].Delete();
                            i = i - 2;
                        }
                    }
                }
            }
            object Line1 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;

            //object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
            emrTaskPane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点

            emrTaskPane.wordApp.Selection.TypeParagraph();                            //插入段落
            Word.Range range1 = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range1.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            int count2 = newTable.Rows.Count - 1;

            range1.Select();
            range1.Text = "记录数共计" + count2 + "条";

            range1.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            range1.Font.Name = "黑体";
            range1.Font.Size = 10f;
            range1.Start     = range.End;
            //Globals.ThisAddIn.ShowNoteMenu();
            //OperationEnableForStat(true);
            Cursor.Current = Cursors.Default;
        }