当前位置: 首页>>代码示例>>C#>>正文


C# Document.Close方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Word.Document.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Close方法的具体用法?C# Document.Close怎么用?C# Document.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Word.Document的用法示例。


在下文中一共展示了Document.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_wordPath);
                _doc.Bookmarks["ДатаЗачисления"].Range.Text = EnrollmentDate.ToShortDateString();
                _doc.Bookmarks["ДатаЗачисления2"].Range.Text = EnrollmentDate.ToShortDateString();
                _doc.Bookmarks["ДатаРождения"].Range.Text = BirthDay.ToShortDateString();
                _doc.Bookmarks["ИдентификационныйНомер"].Range.Text = PassportNumberId;
                _doc.Bookmarks["КатегорияТС"].Range.Text = Program;
                _doc.Bookmarks["МестоРождения"].Range.Text = BirthPlace;
                _doc.Bookmarks["НачалоОбучения"].Range.Text = StartDate.ToShortDateString();
                _doc.Bookmarks["НомерДоговора"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["ПаспортДатаВыдачи"].Range.Text = PassportIssueDate.ToShortDateString();
                _doc.Bookmarks["ПаспортКемВыдан"].Range.Text = PassportIssueBy;
                _doc.Bookmarks["ПаспортСерияНомер"].Range.Text = PassportNumber;
                _doc.Bookmarks["ПостояннаяРегистрация"].Range.Text = Registration;
                _doc.Bookmarks["ПрактикаЧасов"].Range.Text = PracticeHours.ToString();
                _doc.Bookmarks["ПрограммаОбучения"].Range.Text = Program;
                _doc.Bookmarks["Продолжительность"].Range.Text = (PracticeHours + TheoryHours).ToString();
                _doc.Bookmarks["СтоимостьОбучения"].Range.Text = Cost.ToString();
                _doc.Bookmarks["ТелефонСот"].Range.Text = PhoneMobile;
                _doc.Bookmarks["ТеорияЧасов"].Range.Text = TheoryHours.ToString();
                _doc.Bookmarks["ТипГруппы"].Range.Text = GroupType;
                _doc.Bookmarks["ФИОкурсанта"].Range.Text = LastName + " " + Name + " " + MiddleName;
                _doc.Bookmarks["ФИОкурсанта2"].Range.Text = LastName + " " + Name + " " + MiddleName;

                _doc.SaveAs2(FileName: _saveAsPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return _saveAsPath;
        }
开发者ID:IvanNkl,项目名称:AutoSchool,代码行数:41,代码来源:ContractReport.cs

示例2: ExportWord


//.........这里部分代码省略.........
                   BookMark[22] = "tb015";
                   BookMark[23] = "tb016";
                   BookMark[24] = "tb017";
                   BookMark[25] = "tb018";

                   //赋值任意数据到书签的位置
                   string str = "大同333";
                   doc.Bookmarks.get_Item(ref BookMark[0]).Range.Text = "7788";
                   doc.Bookmarks.get_Item(ref BookMark[1]).Range.Text = str;
                   doc.Bookmarks.get_Item(ref BookMark[2]).Range.Text = "50";
                   doc.Bookmarks.get_Item(ref BookMark[3]).Range.Text = "2号";
                   doc.Bookmarks.get_Item(ref BookMark[4]).Range.Text = "6";
                   doc.Bookmarks.get_Item(ref BookMark[5]).Range.Text = "200";

                   //添加图片
                   doc.Bookmarks.get_Item(ref BookMark[7]).Select();
                   app.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                   app.Selection.InlineShapes.AddPicture(@"E:\dzy\picture\12.png", ref missing, ref missing, ref missing);

                   ////判断指定的图片是否存在
                   //if (File.Exists(@"..\..\sources\images\12.png"))
                   //{
                   //    File.Delete(@"..\..\sources\images\12.png");
                   //}

                   #region 表格操作
                   //文档中创建表格
                   Range range = doc.Bookmarks.get_Item(ref BookMark[25]).Range;//表格插入位置
                   Word.Table newTable = doc.Tables.Add(range, 12, 3, ref missing, ref missing);

                   //设置表格样式
                   newTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleThickThinLargeGap;
                   newTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
                   newTable.Columns[1].Width = 100f;
                   newTable.Columns[2].Width = 220f;
                   newTable.Columns[3].Width = 105f;

                   //填充表格内容
                   newTable.Cell(1, 1).Range.Text = "产品详细信息表";
                   newTable.Cell(1, 1).Range.Bold = 2;//设置单元格中字体为粗体

                   //合并单元格
                   newTable.Cell(1, 1).Merge(newTable.Cell(1, 3));
                   //app.Selection.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//垂直居中
                   //app.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;//水平居中

                   //填充表格内容
                   newTable.Cell(2, 1).Range.Text = "产品基本信息";
                   newTable.Cell(2, 1).Range.Font.Color = Word.WdColor.wdColorDarkBlue;//设置单元格内字体颜色

                   //合并单元格
                   newTable.Cell(2, 1).Merge(newTable.Cell(2, 3));
                   //app.Selection.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

                   //填充表格内容
                   newTable.Cell(3, 1).Range.Text = "品牌名称:";
                   newTable.Cell(3, 2).Range.Text = "品牌产地";

                   //纵向合并单元格
                   newTable.Cell(3, 3).Select();//选中一行
                   object moveUnit = Word.WdUnits.wdLine;
                   object moveCount = 5;
                   object moveExtend = Word.WdMovementType.wdExtend;
                   app.Selection.MoveDown(ref moveUnit, ref moveCount, ref moveExtend);
                   app.Selection.Cells.Merge();
                   newTable.Cell(12, 1).Range.Text = "产品特殊属性";
                   newTable.Cell(12, 1).Merge(newTable.Cell(12, 3));

                   //在表格中增加行
                   doc.Content.Tables[1].Rows.Add(ref missing);

                   //“落款”
                   doc.Paragraphs.Last.Range.Text = "文档创建时间:" + DateTime.Now.ToString();
                   doc.Paragraphs.Last.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
            #endregion

                   //输出数据到表格
                   string sql = "select * from 工作面信息表";
                   DataTable dt = db.Query(sql);
                   for (int i = 0; i < dt.Rows.Count; i++)
                   {
                       DataRow dr = dt.Rows[i];
                       string mm = dr["支架柱数"].ToString();
                       doc.Bookmarks.get_Item(ref BookMark[i + 9]).Range.Text = mm;

                   }

                   //输出完毕后关闭doc对象
                   object IsSave = true;
                   doc.Close(ref IsSave, ref missing, ref missing);

                   MessageBox.Show("生成“" + FileName + "”成功!");
               }

               catch (Exception Ex)
               {
                   MessageBox.Show(Ex.ToString());
                   return;
               }
        }
开发者ID:303041859,项目名称:Test,代码行数:101,代码来源:Export.cs

示例3: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["Заказчик"].Range.Text = Customer;
                _doc.Bookmarks["ЗаказчикПодпись"].Range.Text = CustomerInitials;
                _doc.Bookmarks["Исполнитель"].Range.Text = Executor;
                _doc.Bookmarks["ИсполнительПодпись"].Range.Text = ExecutorInitials;
                _doc.Bookmarks["НаименованиеПредприятия"].Range.Text = Organization;
                _doc.Bookmarks["СрокиПорядки"].Range.Text = TimeAndOrders;
                _doc.Bookmarks["СрокНачало"].Range.Text = StartDate.ToShortDateString();
                _doc.Bookmarks["СрокОкончание"].Range.Text = EndDate.ToShortDateString();
                _doc.Bookmarks["Стоимость"].Range.Text = Cost.ToString("C0", new System.Globalization.CultureInfo("be-BY"));
                _doc.Bookmarks["Услуги"].Range.Text = Service;

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:34,代码来源:ContractServiceReport.cs

示例4: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["АрендаВЧас"].Range.Text = CostInHour.ToString("C0", new System.Globalization.CultureInfo("be-BY"));
                _doc.Bookmarks["Часов"].Range.Text = CountHours.ToString();
                _doc.Bookmarks["Арендатор"].Range.Text = Renter;
                _doc.Bookmarks["АрендаторПаспорт"].Range.Text = RenterPassport;
                _doc.Bookmarks["АрендаторТелефон"].Range.Text = RenterPhone;
                _doc.Bookmarks["АрендаторФИО"].Range.Text = RenterFIO;
                _doc.Bookmarks["Арендодатель"].Range.Text = LandLord;
                _doc.Bookmarks["АрендодательАдрес"].Range.Text = LandLordAddress;
                _doc.Bookmarks["АрендодательБанковскиеРеквизиты"].Range.Text = LandLordBank;
                _doc.Bookmarks["АрендодательЛицо"].Range.Text = LandLordFIO;
                _doc.Bookmarks["АрендодательНаименование"].Range.Text = LandLord;
                _doc.Bookmarks["АрендодательТелефон"].Range.Text = LandLordPhone;
                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["ГосНомер"].Range.Text = TransportRegNumber;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["ДатаНачалаДоговора"].Range.Text = ContractStartDate.ToShortDateString();
                _doc.Bookmarks["ДатаНеПозднее"].Range.Text = DateBeforeEnd.ToShortDateString();
                _doc.Bookmarks["ДатаОкончанияДоговора"].Range.Text = ContractEndDate.ToShortDateString();
                _doc.Bookmarks["НазваниеТС"].Range.Text = TransportName;
                _doc.Bookmarks["НазваниеТСКоммЭкс"].Range.Text = TransportName;
                _doc.Bookmarks["НазваниеТССубаренда"].Range.Text = TransportName;
                _doc.Bookmarks["Номер"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["НомерКузова"].Range.Text = TransportEngineNumber;
                _doc.Bookmarks["НомерДвигателя"].Range.Text = TransportBodyNumber;
                _doc.Bookmarks["Пеня"].Range.Text = Fine.ToString();
                _doc.Bookmarks["СколькоЧеловек"].Range.Text = CrewCount.ToString();
                _doc.Bookmarks["СтоимостьАренды"].Range.Text = RentCost.ToString("C0", new System.Globalization.CultureInfo("be-BY"));
                _doc.Bookmarks["ТранспортноеСредство"].Range.Text = TransportName;
                _doc.Bookmarks["ЦелевоеНазначение"].Range.Text = TransportSpecialPurpose;

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:51,代码来源:ContractRentReport.cs

示例5: mgmsExportWord


//.........这里部分代码省略.........
                //            dr_alarmmgms["最小报警值"] = (float)mgmsalamdr.Rows[m]["最小报警值1"];
                //            //----------------------------------------------
                //        }

                //    }
                //    dt_alarmmgms.Rows.Add(dr_alarmmgms);
                //}

                ////--------------------------报警事件的个数-----------------------------

                //for (int n = 0; n < listBox4.Items.Count; n++)
                //{

                //    if (dt_alarmmgms.Rows.Count > 0)
                //    {
                //        //string sensorevent = "锚杆锚索传感器编号='" + sensor[n] + "'";
                //        //MessageBox.Show(sensorevent);
                //        //--------------------判断是否设置报警值的上下限--------------------------
                //        string mgmsselect_str = "";

                //        if (double.IsPositiveInfinity((double)dt_alarmmgms.Rows[n]["最大报警值"]) && double.IsNegativeInfinity((double)dt_alarmmgms.Rows[n]["最小报警值"]))
                //            mgmsselect_str = "1>1";
                //        else if ((double)dt_alarmmgms.Rows[n]["最大报警值"] == -1 && (double)dt_alarmmgms.Rows[n]["最小报警值"] != -1)
                //            mgmsselect_str = "锚杆锚索data<" + (double)dt_alarmmgms.Rows[n]["最小报警值"];
                //        //"锚杆锚索传感器编号='" + listBox4.Items[p].ToString()+"'"
                //        else if ((double)dt_alarmmgms.Rows[n]["最大报警值"] != -1 && (double)dt_alarmmgms.Rows[n]["最小报警值"] == -1)
                //        {
                //            mgmsselect_str = "锚杆锚索data>" + (double)dt_alarmmgms.Rows[n]["最大报警值"];
                //            //MessageBox.Show(mgmsselect_str);
                //        }
                //        else
                //            mgmsselect_str = "锚杆锚索data>" + (double)dt_alarmmgms.Rows[n]["最大报警值"] + " or " + "锚杆锚索data<" + (double)dt_alarmmgms.Rows[n]["最小报警值"];
                //        //MessageBox.Show(dt_alarm.Rows[n]["传感器编号"].ToString());
                //        //--------------------------------------------------------------------------------------------

                //        //--------------------------------取已设报警值的锚杆锚索传感器编号-----------------
                //        string mgmsalamsensorno = "锚杆锚索传感器编号='" + listBox4.Items[n].ToString() + "'";
                //        //for (int i = 0; i <= dt_alarmmgms.Rows.Count; i++)
                //        //{
                //        //    if (i == dt_alarmmgms.Rows.Count - 1)
                //        //    {
                //        //        mgmsalamsensorno += dt_alarmmgms.Rows[i]["传感器编号"].ToString() + "'";
                //        //        //MessageBox.Show(alamsensono);
                //        //    }
                //        //    //else
                //        //    // alamsensono += dt_alarm.Rows[i]["传感器编号"].ToString() + "' or 锚杆锚索传感器编号='";

                //        //}
                //        //---------------------------------------------------------------------

                //        string sqlalameventmgms = "select 锚杆锚索传感器编号,锚杆锚索data,锚杆锚索观测时间 from 锚杆锚索传感器信息表 where(" + mgmsalamsensorno + ") and ( [锚杆锚索观测时间] Between  #" + d_beginmgms + "# And #" + d_overmgms + "#) ";
                //        DataTable mgmsalramnodt = db.Query(sqlalameventmgms);//存锚杆锚索传感器编号符合条件的报警值
                //        if (mgmsselect_str != "")
                //        {
                //            //if(double.IsPositiveInfinity(num);)
                //            DataRow[] alarmmgms = mgmsalramnodt.Select(mgmsselect_str); //存所有报警值
                //            // DataRow[] alammin = alamnodt.Select("锚杆锚索data<" + mgmsalameventmin);

                //            if (alarmmgms.Length == 1)
                //                doc.Bookmarks.get_Item(ref BookMark[n + 59]).Range.Text = alarmmgms[0]["锚杆锚索data"].ToString() + "/" + alarmmgms[0]["锚杆锚索观测时间"].ToString() + " ";
                //            else if (alarmmgms.Length > 1)
                //                doc.Bookmarks.get_Item(ref BookMark[n + 59]).Range.Text = "共发生" + alarmmgms.Length.ToString() + "个报警事件";
                //            else
                //                doc.Bookmarks.get_Item(ref BookMark[n + 59]).Range.Text = "无";
                //        }
                //    }

                //}

                //-----------------------添加图片-----------------------------------------
                doc.Bookmarks.get_Item(ref BookMark[68]).Select();
                app.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                app.Selection.InlineShapes.AddPicture(@"D:\c.bmp", ref missing, ref missing, ref missing);

                ////判断指定的图片是否存在
                //if (File.Exists(@"..\..\sources\images\12.png"))
                //{
                //    File.Delete(@"..\..\sources\images\12.png");
                //}

                //-------------------------------------------------------------------------------------

                #endregion

                MessageBox.Show("生成“" + newFileName + "”成功!");
            }

            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
                return;
            }

            finally
            {
                //输出完毕后关闭doc对象
                object IsSave = true;
                doc.Close(ref IsSave, ref missing, ref missing);
            }
        }
开发者ID:303041859,项目名称:Test,代码行数:101,代码来源:multipleQuery.cs

示例6: dblcExportWord


//.........这里部分代码省略.........
            {

                //生成word程序对象

                doc.Activate();

                //-----------数据煤矿名称读取操作----------
                string strsqltitle = "select 煤矿名称 from 煤矿基本信息表 ";
                DataTable dt = db.Query(strsqltitle);
                DataRow dr = dt.Rows[0];
                string inform = dr["煤矿名称"].ToString();
                //----------------------------------------------------------
                //获取当前系统时间不显示秒
                DateTime currentTime = System.DateTime.Now;
                string strnowtime = currentTime.ToString("f");

                //获取当前用户
                string currentuser = login.REAL_NAME;

                #region 导出报表
                //---------------------取时间段-------------------
                string date_begin_hourdblc = (comboBox1.Text == "") ? "0" : comboBox1.Text;
                string date_begin_mindblc = (comboBox3.Text == "") ? "0" : comboBox3.Text;
                string date_over_hourdblc = (comboBox2.Text == "") ? "23" : comboBox2.Text;
                string date_over_mindblc = (comboBox4.Text == "") ? "59" : comboBox4.Text;

                string date_begindblc = dateTimePicker3.Text.ToString();
                date_begindblc += " " + date_begin_hourdblc + ":" + date_begin_mindblc;
                date_begindblc += ":00";
                string date_overdblc = dateTimePicker4.Text.ToString();
                date_overdblc += " " + date_over_hourdblc + ":" + date_over_mindblc;
                date_overdblc += ":00";
                DateTime d_begindblc = DateTime.Parse(date_begindblc);
                DateTime d_overdblc = DateTime.Parse(date_overdblc);

                //----赋值dblc数据到公共书签的位置---------------------
                doc.Bookmarks.get_Item(ref BookMark_db[0]).Range.Text = inform;
                doc.Bookmarks.get_Item(ref BookMark_db[1]).Range.Text = date_begindblc;
                doc.Bookmarks.get_Item(ref BookMark_db[2]).Range.Text = date_overdblc;
                doc.Bookmarks.get_Item(ref BookMark_db[3]).Range.Text = strnowtime;
                doc.Bookmarks.get_Item(ref BookMark_db[4]).Range.Text = currentuser;
                //-------------------------------------------------------------

                //---------------取传感器编号与所选传感器列表相对应----------
                string cgqbh = "";
                //int row_num = 0;
                int i;
                for (i = 0; i < dataGridView2.Rows.Count; i++)
                {
                    cgqbh = dataGridView2.Rows[i].Cells["传感器编号"].Value.ToString();
                    int dblcid = -1;
                    dblcfillword(cgqbh, ref doc, i, d_begindblc, d_overdblc, out dblcid);

                    string sql = "SELECT  顶板离层传感器编号,离层data1 as data1,离层data2 as data2 FROM 顶板离层传感器信息表 WHERE  顶板离层ID=" + dblcid;
                    DataTable dtdblc = db.Query(sql);
                    if (dtdblc.Rows.Count > 0)
                    {
                        doc.Bookmarks.get_Item(ref BookMark_db[i + 14]).Range.Text = dtdblc.Rows[0]["data" + Tools.conn_order(cgqbh, "深基点").ToString()].ToString();
                        doc.Bookmarks.get_Item(ref BookMark_db[i + 23]).Range.Text = dtdblc.Rows[0]["data" + Tools.conn_order(cgqbh, "浅基点").ToString()].ToString();
                    }

                }

                //------------------------------------------------------------------------------------
                doc.Bookmarks.get_Item(ref BookMark_db[59]).Select();
                app.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //app.Selection.ParagraphFormat.AutoAdjustRightIndent=;
                InlineShape lipt = app.Selection.InlineShapes.AddPicture(@"D:\b.bmp", ref missing, ref missing, ref missing);

                ////-----------------------添加图片-----------------------------------------
                //doc.Bookmarks.get_Item(ref BookMark_zz[47]).Select();
                //app.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //app.Selection.InlineShapes.AddPicture(@"E:\dzy\picture\12.png", ref missing, ref missing, ref missing);

                //////判断指定的图片是否存在
                ////if (File.Exists(@"..\..\sources\images\12.png"))
                ////{
                ////    File.Delete(@"..\..\sources\images\12.png");
                ////}

                ////-------------------------------------------------------------------------------------

                #endregion

                MessageBox.Show("生成“" + newFileName + "”成功!");
            }

            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
                return;
            }

            finally
            {
                //输出完毕后关闭doc对象
                object IsSave = true;
                doc.Close(ref IsSave, ref missing, ref missing);
            }
        }
开发者ID:303041859,项目名称:Test,代码行数:101,代码来源:multipleQuery.cs

示例7: ImprimirReportes


//.........这里部分代码省略.........
                        fechapago = fechapago.AddMonths(1).Date;
                        break;
                }

            }
            XrptControlPagosGrupal control = new XrptControlPagosGrupal();
            control.DataSource = financieraDS.Tables[0];
            control.DatosGrupo.DataSource = credito;
            control.MontoCredito.Value = Convert.ToDecimal(txtCantidadCredito.EditValue);
            control.DiasPago.Value = string.Format("LOS {0} DE CADA SEMANA (CON PRORROGA HASTA EL {1})", dtpFechaInicio.DateTime.ToString("dddd").ToUpper(), dtpFechaInicio.DateTime.AddDays(Convert.ToInt32(txtProrrogaG.EditValue)).ToString("dddd").ToUpper());
            //control.ShowPreviewDialog();
            control.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            control.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));

            foreach (DataRow fila in dtIntegrantesGrupo.Rows)
            {
                fechapago = dtpFechaInicio.DateTime.Date;
                financieraDS.Tables[1].Rows.Clear();
                financieraDS.Tables[1].AcceptChanges();
                financieraDS.Tables[1].Columns["Pago"].AutoIncrementSeed = -1;
                financieraDS.Tables[1].Columns["Pago"].AutoIncrementStep = -1;
                financieraDS.Tables[1].Columns["Pago"].AutoIncrementSeed = 1;
                financieraDS.Tables[1].Columns["Pago"].AutoIncrementStep = 1;
                for (int i = 0; i < Convert.ToInt32(txtNumPlazos.EditValue); i++)
                {
                    switch (cboPlazo.Text)
                    {
                        case "SEMANAL":
                            financieraDS.Tables[1].Rows.Add(new[] { fila[1], fila[8], fila[9], fila[3], fechapago.AddDays(7).Date, null });
                            fechapago = fechapago.AddDays(7).Date;
                            break;
                        case "QUINCENAL":
                            financieraDS.Tables[1].Rows.Add(new[] { fila[1], fila[8], fila[9], fila[3], fechapago.AddDays(15).Date, null });
                            fechapago = fechapago.AddDays(15).Date;
                            break;
                        case "MENSUAL":
                            financieraDS.Tables[1].Rows.Add(new[] { fila[1], fila[8], fila[9], fila[3], fechapago.AddMonths(1).Date, null });
                            fechapago = fechapago.AddMonths(1).Date;
                            break;
                    }
                }
                XrptControlPagosPersonal control1 = new XrptControlPagosPersonal();
                control1.DataSource = financieraDS.Tables[1];
                control1.DatosGrupo.DataSource = credito;
                control1.MontoCredito.Value = Convert.ToDecimal(txtCantidadCredito.EditValue);
                control1.DiasPago.Value = string.Format("LOS {0} DE CADA SEMANA (CON PRORROGA HASTA EL {1})", dtpFechaInicio.DateTime.ToString("dddd").ToUpper(), dtpFechaInicio.DateTime.AddDays(Convert.ToInt32(txtProrrogaG.EditValue)).ToString("dddd").ToUpper());
                control1.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
                //financieraDS.Tables[2].Rows.Add(new[] { fila[1],CbToBytesA((Bitmap)fila[5]), CbToBytesA((Bitmap)fila[6]), CbToBytesA((Bitmap)fila[7])});
            }
            financieraDS.Tables[1].Rows.Clear();
            foreach (DataRow fila in dtIntegrantesGrupo.Rows)
            {
                financieraDS.Tables[1].Rows.Add(new[] { fila[1], fila[8], fila[9], fila[3], fechapago.AddDays(7).Date, null });
            }
            XrptHistrorialPagoPersonal historial = new XrptHistrorialPagoPersonal();
            historial.DataSource = financieraDS;
            historial.DatosGrupo.DataSource = credito;
            historial.MontoCredito.Value = Convert.ToDecimal(txtCantidadCredito.EditValue);
            historial.DiasPago.Value = dtpFechaInicio.DateTime.ToString("dddd").ToUpper();
            XRSubreport detailReport = historial.Bands[BandKind.ReportHeader].FindControl("xrSubreport1", true) as XRSubreport;
            detailReport.ReportSource.DataSource = financieraDS.Tables[1];

            //for (int i = 0; i < dtIntegrantesGrupo.Rows.Count; i++)
            //{
            historial.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            historial.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            //}
            XrptPoderCobranza poder = new XrptPoderCobranza();
            poder.DataSource = credito;
            //poder.ShowPreviewDialog();
            poder.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            XrptReglamento reglamento = new XrptReglamento();
            reglamento.DataSource = credito;
            reglamento.BaseLetras.Value = String.Format("{0} ({1}) ", txtBase.Text, Conversiones.NumeroALetras(txtBase.EditValue.ToString()));
            reglamento.Presidenta.Value =
                credito.FinancieraGrupo.FinancieraGruposDetalles.First(p => p.Tipo == "PRESIDENTA").FinancieraCliente.Nombre;
            reglamento.Tesorera.Value =
                credito.FinancieraGrupo.FinancieraGruposDetalles.First(p => p.Tipo == "TESORERA").FinancieraCliente.Nombre;
            reglamento.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            reglamento.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            //reglamento.ShowPreviewDialog();
            //control.Pages.AddRange(historial.Pages);
            this.oWord = new Word.Application();
            this.oWord.Visible = false;

            // Ubicación de la plantilla en el disco duro
            oDoc = oWord.Documents.Add(Application.StartupPath + @"\Reglamento.dotx");
            oDoc.Bookmarks["Sucursal"].Range.Text = new clsModificarConfiguracion().configGetValue("Empresa");
            oDoc.Bookmarks["Direccion"].Range.Text = new clsModificarConfiguracion().configGetValue("Direccion");
            object m = System.Reflection.Missing.Value;
            object copies = 2;
            oWord.ActivePrinter = new clsModificarConfiguracion().configGetValue("ImpresoraBoletas");
            oWord.PrintOut(m, m, m, m, m, m, m, copies, m, m, m, m, m, m, m, m, m, m, m);
            object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
            oDoc.Close(ref doNotSaveChanges, m, m);

            //////XrptFotosGrupos fotos=new XrptFotosGrupos {DataSource = financieraDS.Tables[2]};
            ////////fotos.ShowPreviewDialog(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
            //////fotos.Print(new clsModificarConfiguracion().configGetValue("ImpresoraBoletas"));
        }
开发者ID:JC-Developers,项目名称:SoftEmpeniosCergo,代码行数:101,代码来源:FrmCreditos.cs

示例8: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Арендатор"].Range.Text = Renter;
                _doc.Bookmarks["АрендаторФИО"].Range.Text = RenterFIO;
                _doc.Bookmarks["Арендодатель"].Range.Text = LandLord;
                _doc.Bookmarks["АрендодательФИО"].Range.Text = Director;
                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["ГосНомер1"].Range.Text = TransportRegNumber;
                _doc.Bookmarks["ГосНомер2"].Range.Text = TransportRegNumber;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["Директор"].Range.Text = LandLordFIO;
                _doc.Bookmarks["Номер"].Range.Text = Number.ToString();
                _doc.Bookmarks["Транспорт1"].Range.Text = TransportName;
                _doc.Bookmarks["Транспорт2"].Range.Text = TransportName;

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:35,代码来源:ActRentReport.cs

示例9: button6_Click


//.........这里部分代码省略.........

                MySqlConnection myConnection2 = new MySqlConnection(Connect);
                MySqlCommand updateCommand = new MySqlCommand(CommandText, myConnection2);
                myConnection2.Open();
                // Gets a NumberFormatInfo associated with the en-US culture.
                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

                nfi.NumberDecimalDigits = 0;
                nfi.NumberGroupSeparator = " ";

                nfi.PositiveSign = "";
                MySqlDataReader MyDataReader;
                string date; //Получаем дату
                string phone; //Получаем строку
                string header; //Получаем строку
                string text; //Получаем строку
                int cost; //Получаем строку
                string catalog; //Получаем строку
                int toshow; //Получаем строку
                string id;
                MyDataReader = myCommand.ExecuteReader();

                while (MyDataReader.Read())
                {

                    header = MyDataReader.GetString(12); //Получаем строку
                    text = MyDataReader.GetString(13); //Получаем строку
                    phone = MyDataReader.GetString(14); //Получаем строку
                    id = MyDataReader.GetString(0); //Получаем id
                    cost = MyDataReader.GetInt32(20); //Получаем строку
                    //toshow = MyDataReader.GetUInt16(9); //Получаем строку
                    //catalog = MyDataReader.GetString(11); //Получаем строку

                    // wdApp.Selection.ClearFormatting();
                    // wdApp.Selection.Select();
                    //  wdApp.Selection.Characters.Last.Select();
                    wdApp.Selection.Font.Bold = 1;
                    wdApp.Selection.TypeText("" + cost.ToString("N", nfi));
                    wdApp.Selection.TypeText(" ");
                    // wdApp.Selection.Font.Bold = 0;
                    // wdApp.Selection.Select();
                    //  wdApp.Selection.Characters.Last.Select();
                    //  wdApp.Selection.ClearFormatting();
                    wdApp.Selection.Font.Bold = 0;
                    wdApp.Selection.TypeText(" руб.");
                    //wdApp.Selection.Font.Bold = 1;
                    wdApp.Selection.TypeParagraph();
                    // wdApp.Selection.Select();
                    //  wdApp.Selection.Characters.Last.Select();

                    //  wdApp.Selection.ClearFormatting();
                    //  wdApp.Selection.Font.Bold = 0;
                    wdApp.Selection.TypeText(header);
                    //  wdApp.Selection.Font.Bold = 0;
                    //  wdApp.Selection.Select();
                    //  wdApp.Selection.Characters.Last.Select();
                    //  wdApp.Selection.Font.Bold = 0;
                    //  wdApp.Selection.ClearFormatting();
                    wdApp.Selection.TypeText(" - " + text + " ");
                    //  wdApp.Selection.Select();
                    //  wdApp.Selection.Characters.Last.Select();
                    wdApp.Selection.TypeText(" " + phone);
                    //  wdApp.Selection.Font.Bold = 0;
                    wdApp.Selection.TypeParagraph();
                    //wdApp.Selection.TypeParagraph();
                    CommandText = "UPDATE `" + dbname + "`.`ob` SET `secondRub`='" + idRub + "' WHERE `ID_OB`='" + id + "'";
                    //MessageBox.Show(CommandText);
                    updateCommand.CommandText = CommandText;
                    int res = updateCommand.ExecuteNonQuery();
                    col++;
                    if (checkBox2.Checked)
                    {
                        //CommandText = "UPDATE `ads_paper`.`cards` SET `toshow`=" + (toshow - 1).ToString() + " WHERE `date`='" + date + "'";
                        //MessageBox.Show(CommandText);

                        //MySqlCommand updateCommand = new MySqlCommand(CommandText, myConnection2);
                        //int res = updateCommand.ExecuteNonQuery();
                    }

                }

                MyDataReader.Close();
                myConnection2.Close();
                myConnection.Close(); //Обязательно закрываем соединение!

                wdApp.ActiveDocument.SaveAs("Квартиры.doc");
                wdDoc.Close();
                //wdApp.Documents.Close();
                wdApp.Quit();

                //wdApp.Selection.TypeText("l");
                // Print each node recursively.

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
开发者ID:Yaponiz,项目名称:AdvertBase,代码行数:101,代码来源:ExportForm.cs

示例10: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора2"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора3"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["ДатаОкончания"].Range.Text = EndDate.ToShortDateString();
                _doc.Bookmarks["Директор"].Range.Text = Director;
                _doc.Bookmarks["Заказчик"].Range.Text = Customer;
                _doc.Bookmarks["ЗаказчикФИО"].Range.Text = CustomerFIO;
                _doc.Bookmarks["НомерДоговора"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["НомерДоговора2"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["НомерДоговора3"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["ПаспортВыдан"].Range.Text = string.Format("{0} {1} г.", PassportIssuedBy, PassportIssuedDate.ToShortDateString());
                _doc.Bookmarks["ПаспортНомер"].Range.Text = PassportNumber;
                _doc.Bookmarks["ПаспортСерия"].Range.Text = PassportSeries;
                _doc.Bookmarks["Подрядчик"].Range.Text = Contractor;
                _doc.Bookmarks["ПодрядчикФИО"].Range.Text = ContractorFIO;
                _doc.Bookmarks["Работы"].Range.Text = Services;
                _doc.Bookmarks["ФактическаяДатаОкончания"].Range.Text = ActualEndDate.ToShortDateString();

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:41,代码来源:ActServiceReport.cs

示例11: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
               /* if (catalogsComboBox.SelectedIndex == 1)
                 {*/
                col = 0;
                    Microsoft.Office.Interop.Word.Application wdApp = new Microsoft.Office.Interop.Word.Application();
                    Microsoft.Office.Interop.Word.Document wdDoc = new Microsoft.Office.Interop.Word.Document();
                    wdDoc = wdApp.Documents.Add();
                    wdDoc.SpellingChecked = false;

                    wdDoc.ShowSpellingErrors = false;
                    wdApp.Selection.Font.Name = "Times New Roman";
                    wdApp.Selection.Font.Size = 12;
                    wdApp.ActiveDocument.Select();

                    string CommandText = "select * from `ads_paper`.`catalogItems` order by R1,R2,R3,R4";
                    string Connect = "Database=" + dbname + ";Data Source=" + server + ";User Id=" + dbuser + ";Password=" + dbpass + ";Port="+dbPort;

                MySqlConnection myConnection = new MySqlConnection(Connect);
                MySqlCommand myCommand = new MySqlCommand(CommandText, myConnection);
                myConnection.Open(); //Устанавливаем соединение с базой данных.
                MySqlDataReader MyDataReader;

                bool state = false;
                MyDataReader = myCommand.ExecuteReader();
                int[] catID = new int[5];
                while (MyDataReader.Read())
                {
                    catID[0] = MyDataReader.GetInt32(0);
                    catID[1] = MyDataReader.GetInt32(2);
                    catID[2] = MyDataReader.GetInt32(3);
                    catID[3] = MyDataReader.GetInt32(4);
                    catID[4] = MyDataReader.GetInt32(5);
                    string name = MyDataReader.GetString(1); //Получаем строку

                    if (checkCount(catID))
                    {

                        wdApp.Selection.TypeParagraph();
                        if (catID[2] == 0)
                        {
                            wdApp.Selection.TypeText("@@" + catID[1].ToString());
                            wdApp.Selection.TypeParagraph();
                            wdApp.Selection.TypeParagraph();
                            wdApp.Selection.TypeText(name);
                            wdApp.Selection.TypeParagraph();
                            wdApp.Selection.TypeParagraph();

                        }
                        else if (catID[3] == 0)
                        {
                            if (catID[1] == 1 || catID[1] == 4 || catID[1] == 5 || catID[1] == 11 || catID[1] == 18)
                            {
                                wdApp.Selection.TypeText("-" + catID[1].ToString() + "." + catID[2].ToString() + "-");
                            }
                            else
                            {
                                wdApp.Selection.TypeText(catID[1].ToString() + "." + catID[2].ToString());
                            }

                            wdApp.Selection.TypeText(" "+name);
                            wdApp.Selection.TypeParagraph();
                            state = true;

                        }
                        else
                        {
                            //if (state == true)
                            //{
                            //    wdApp.Selection.TypeParagraph();
                            //}

                            wdApp.Selection.TypeText(name);
                            wdApp.Selection.TypeParagraph();
                            wdApp.Selection.TypeParagraph();
                            state = false;
                        }

                        PrintAdsOB(catID, ref wdApp);

                    }
                }
                MyDataReader.Close();
                myConnection.Close();
                ReplaceTextWord(ref wdApp, "  ", " ");
                wdApp.ActiveDocument.SaveAs("Объявления.doc");
                wdDoc.Close();
                //wdApp.Documents.Close();
                wdApp.Quit();
                MessageBox.Show("Выгрузка завершена, выгружено: "+col.ToString()+" объявлений");
                //mainForm f = new mainForm();
                    //f.catalogSelector.Select(1, 1);
                   /* TreeNodeCollection nodes = f.catalogList.Nodes;
                    foreach (TreeNode groupeNode in nodes)
                    {
                        PrintRecursive(groupeNode, ref wdApp);
                    }

//.........这里部分代码省略.........
开发者ID:Yaponiz,项目名称:AdvertBase,代码行数:101,代码来源:ExportForm.cs

示例12: GetReport

 public string GetReport()
 {
     try
     {
         _wordApp = new Word.Application();
         _doc = _wordApp.Documents.Add(_wordPath);
         _doc.Bookmarks["ГодРождения"].Range.Text = BirthDay.Year.ToString().Trim();
         _doc.Bookmarks["Гражданство"].Range.Text = Nationality;
         _doc.Bookmarks["ДатаЗачисления"].Range.Text = EnrollmentDate.ToShortDateString();
         _doc.Bookmarks["ДатаМесяцРождения"].Range.Text = BirthDay.Day + " " + GetMonthName(BirthDay.Month);
         _doc.Bookmarks["Должность"].Range.Text = JobPosition;
         _doc.Bookmarks["МедСправка"].Range.Text = "№" + MedicalNumber + " от " + MedicalDate.ToShortDateString() + ", " + MedicalName;
         _doc.Bookmarks["МестоРаботы"].Range.Text = Job;
         _doc.Bookmarks["МестоРождения"].Range.Text = BirthPlace;
         _doc.Bookmarks["Образование"].Range.Text = Education;
         _doc.Bookmarks["ОтФИО"].Range.Text = FIO;
         _doc.Bookmarks["ПаспортВыдан"].Range.Text = PassportIssueBy + " " + PassportIssueDate.ToShortDateString();
         _doc.Bookmarks["ПаспортСерия1"].Range.Text = PassportNumber.Substring(0, 2);
         _doc.Bookmarks["ПаспортСерия2"].Range.Text = PassportNumber.Substring(3, PassportNumber.Length - 3);
         _doc.Bookmarks["Программа"].Range.Text = Program;
         _doc.Bookmarks["Регистрация"].Range.Text = Registration;
         _doc.Bookmarks["ТелДом"].Range.Text = PhoneHome;
         _doc.Bookmarks["ТелМоб"].Range.Text = PhoneMobile;
         _doc.Bookmarks["ФИО"].Range.Text = LastName + " " + Name + " " + MiddleName;
         _doc.SaveAs2(FileName: _saveAsPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);
     }
     catch (Exception)
     {
     }
     finally
     {
         _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
         _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
     }
     return _saveAsPath;
 }
开发者ID:IvanNkl,项目名称:AutoSchool,代码行数:36,代码来源:StatementReport.cs

示例13: Button1_Click

 protected void Button1_Click(object sender, EventArgs e)
 {
     object Nothing = System.Reflection.Missing.Value;//定义一个missing
     wordApp = new Msword.ApplicationClass();//对wordapp进行初始化
     wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);//对一个wordDoc进行初始化
     object filename = "F:\\aa.doc";
     if (File.Exists(filename.ToString()))//判断文件是否存在
     {
         File.Delete(filename.ToString());//若文件存在就删除这个文件
     }
     wordApp.Visible = false;//设置动态建立的word文档可见
     wordApp.Selection.PageSetup.LeftMargin = wordApp.CentimetersToPoints(float.Parse("2"));//设置word文档的左边距
     wordApp.Selection.PageSetup.RightMargin = wordApp.CentimetersToPoints(float.Parse("2"));//设置word文档右边距
     wordApp.ActiveWindow.HorizontalPercentScrolled = 11;//设置文档的水平滑动距离
     wordApp.ActiveWindow.View.Type = Msword.WdViewType.wdOutlineView;//设置文档的页眉类型
     wordApp.ActiveWindow.View.SeekView = Msword.WdSeekView.wdSeekCurrentPageHeader;//设置文档的页眉是显示在文档的头部
     wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("这是我的页眉内容");
     wordApp.Selection.ParagraphFormat.Alignment = Msword.WdParagraphAlignment.wdAlignParagraphRight;//设置页眉内容的对齐方式
     //wordApp.ActiveWindow.View.SeekView = Msword.WdSeekView.wdSeekMainDocument;//跳出页眉设置
     wordApp.Selection.ParagraphFormat.LineSpacing = 11f;//设置段落的距离为11f
     Msword.Paragraph para1;//定义一个段落为para1
     para1 = wordDoc.Paragraphs.Add(ref Nothing);//对para1进行初始化
     para1.Range.Text = "这是我的内容2这是我的内容2这是我的内容2这是我的内容2这是我的内容2这是我的内容2这是我的内容2这是我的内容2这是我的内容2";//对段落para1进行添加内容
     para1.Format.CharacterUnitFirstLineIndent = 2;//设置首行缩进
     para1.Range.Font.Color = Msword.WdColor.wdColorBlue;//设置字体的颜色
     para1.Format.SpaceAfter = 6;//在段落para1后面设置空行为6
     para1.Range.InsertParagraphAfter();//将段落para1添加到文档中
     Msword.Paragraph para2;//同上
     object endofdoc = "\\endofdoc";//定义标签endofdoc,"endofdoc"表示文档的末尾书签
     object range1 = wordDoc.Bookmarks.get_Item(ref endofdoc).Range;//定位到文档的书签处
     para2 = wordDoc.Paragraphs.Add(ref range1);//同上
     para2.Range.Text = "asfdasdfasdfasdffasdfsadfasdfasfdasdfas";//同上
     para2.Range.InsertParagraphAfter();//同上
     Msword.Paragraph para3;//同上
     object range2 = wordDoc.Bookmarks.get_Item(ref endofdoc).Range;//同上
     para3 = wordDoc.Paragraphs.Add(ref range2);//同上
     para3.Range.Text = "eeeeeeeeeeeeeeeeeeeeeeee";//同上
     object sttar = (object)(para3.Range.Start + 2);//"para3.Range.Start "表示para3段落的开始处加上两个字符
     object eend = (object)(para3.Range.Start + 2);//同上
     wordDoc.Range(ref sttar, ref eend).InsertBefore("ttt");//定位到para3段落的开始处加上两个字符并添加内容"ttt"
     para3.Format.CharacterUnitFirstLineIndent = 2;//设置首行缩进
     para3.Range.Font.Bold = 5;//设置段落para3字体颜色
     para3.Range.InsertParagraphAfter();//同上
     Msword.Table table1 = wordDoc.Tables.Add(para3.Range, 8, 8, ref Nothing, ref Nothing);//在文档中添加8行8列的表格
     table1.Cell(1, 1).Range.Font.Color = Msword.WdColor.wdColorBrown;//设置表格中的第1行1列的字体颜色为wdColorBrown
     table1.Cell(1, 1).Range.Text = "搜点的撒旦";//在表格中的第一行第一类中添加内容
     table1.Range.ParagraphFormat.Alignment = Msword.WdParagraphAlignment.wdAlignParagraphRight;//设置表格中的内容alignment
     table1.Cell(3, 3).Merge(table1.Cell(8, 3));//将3行3列一直到8行3列进行组合成一列
     object row = 4;
     object col = 4;
     table1.Cell(3, 1).Split(ref row, ref col);//将3行1列分开为4行4列
     string picturefile = "D:\\ly\\应用\\test.jpg";//设置图片的路径
     object linktofile = false;
     object linktodoctument = true;
     object x1 = (object)(para2.Range.Start);
     object x2 = (object)(para2.Range.End);
     object rr1 = wordDoc.Range(ref x1, ref x2);
     wordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picturefile, ref linktofile, ref linktodoctument, ref rr1);//将图片添加到文档中
     //将图片的外形设置为可变
     Msword.Shape shape1 = wordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape();
     shape1.WrapFormat.Type = Msword.WdWrapType.wdWrapSquare;
     //保存wordDoc
     wordDoc.SaveAs(ref filename, 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, ref Nothing);
     //释放内存
     wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
     wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
 }
开发者ID:Angliy,项目名称:DemoForTest,代码行数:69,代码来源:Default9.aspx.cs

示例14: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Адрес"].Range.Text = Address;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["Директор"].Range.Text = Director;
                _doc.Bookmarks["НаименованиеПредприятия"].Range.Text = Organization;
                _doc.Bookmarks["ОтФИО"].Range.Text = string.Format("{0} {1}. {2}.", LastName, Name.Substring(0, 1), MiddleName.Substring(0, 1));
                _doc.Bookmarks["ПаспортВыдан"].Range.Text = string.Format("{0} {1} г.", PassportIssuedBy, PassportIssuedDate.ToShortDateString());
                _doc.Bookmarks["ПаспортНомер"].Range.Text = PassportNumber;
                _doc.Bookmarks["ПаспортСерия"].Range.Text = PassportSeries;
                _doc.Bookmarks["Телефон"].Range.Text = Phone;
                _doc.Bookmarks["Услуга"].Range.Text = Service;
                _doc.Bookmarks["ФИО"].Range.Text = string.Format("{0} {1} {2}", LastName, Name, MiddleName);

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:33,代码来源:StatementReport.cs

示例15: CreateWordsDocumentToOne

        public static bool CreateWordsDocumentToOne(object docPath, string savaAs, string docName,DataRowView[] candidats,string presedinte,string membru1, string membru2)
        {
            int candiLength = candidats.Length;
               Console.WriteLine("LENGTH" + candiLength);

               object missing = Missing.Value;
             //      Word.Document[] adocs = new Word.Document[candidats.Length];

               string output = savaAs + docName + "-" + "candidats.docx";

               Application createEmptyDocApp = null;
               Word.Document createEmptyDoc = null;

               Word._Application wordAppForOutput = null;
               Word._Document wordDocument = null;

               Word.Document aDoc = null;
               Word.Application wordApp = null;

               try
               {
               if (File.Exists(output))
                   File.Delete(output);

               if (!File.Exists(output))
               {
                   createEmptyDocApp = new Application();
                   createEmptyDoc = createEmptyDocApp.Documents.Add();

                   createEmptyDocApp.ActiveDocument.SaveAs(output, ref missing, ref missing,
                                                                          ref missing, ref missing, ref missing, ref missing,
                                                                          ref missing, ref missing, ref missing, ref missing);
                   createEmptyDoc.Close();
                   if (createEmptyDocApp != null)
                   {
                       createEmptyDocApp.Quit();
                       Marshal.FinalReleaseComObject(createEmptyDocApp);
                   }

                   createEmptyDoc = null;
                   createEmptyDocApp = null;

               }
               else
               {
                   return false;
               }

               object pageBreak = Word.WdBreakType.wdPageBreak;
               wordAppForOutput = new Word.Application();

               wordAppForOutput.Visible = false;

               wordDocument = wordAppForOutput.Documents.Open(
                                             output
                                             , false, false, ref missing,
                                                        ref missing, ref missing, ref missing, ref missing,
                                                        ref missing, ref missing, ref missing, true,
                                                        ref missing, ref missing, ref missing, ref missing);

               wordDocument.Activate();

               for (int i = 0; i < candiLength; ++i)
               {

                   aDoc = new Word.Document();
                   wordApp = new Word.Application();
                   DataRow candidat = candidats[i].Row;
                   List<int> processesbeforegen = getRunningProcesses();
                   // string savePath =(string) savaAs + docName + " " + candidat["Nume"] + "_" + candidat["Prenume"] ;
                   string savePath = savaAs + "tempDoc";

                   if (File.Exists((string)docPath))
                   {
                       Console.WriteLine("Fajlnal vagyok");

                       object readOnly = false; //default
                       object isVisible = false;

                       wordApp.Visible = false;

                       aDoc = wordApp.Documents.Open(ref docPath, ref missing, ref readOnly,
                                                   ref missing, ref missing, ref missing,
                                                   ref missing, ref missing, ref missing,
                                                   ref missing, ref missing, ref missing,
                                                   ref missing, ref missing, ref missing, ref missing);

                       aDoc.Activate();

                       Console.WriteLine("megnyitva");

                       //Find and replace:
                       FindAndReplace(wordApp, "{NrMatricol}", candidat["NrMatricol"]);
                       FindAndReplace(wordApp, "{Nume}", candidat["Nume"]);
                       FindAndReplace(wordApp, "{Prenume}", candidat["Prenume"]);
                       FindAndReplace(wordApp, "{Tata}", candidat["Tata"]);
                       FindAndReplace(wordApp, "{Mama}", candidat["Mama"]);
                       FindAndReplace(wordApp, "{CNP>", candidat["CNP"]);
                       FindAndReplace(wordApp, "{DataNasterii}", candidat["DataNasterii"]);
                       FindAndReplace(wordApp, "{LoculNasterii}", candidat["LoculNasterii"]);
//.........这里部分代码省略.........
开发者ID:koppandiatt,项目名称:faszomxitprojekt,代码行数:101,代码来源:Report.cs


注:本文中的Microsoft.Office.Interop.Word.Document.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。