Example #1
0
        /// <summary>
        /// 保存并退出Word,保存为97-2003格式
        /// </summary>
        /// <param name="_path">保存路径</param>
        public void SaveAndQuit(object _path)
        {
            object format = MSWord.WdSaveFormat.wdFormatDocument97;

            Doc.SaveAs2(ref _path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            Doc.Close(ref Nothing, ref Nothing, ref Nothing);
            App.Quit(ref Nothing, ref Nothing, ref Nothing);
        }
Example #2
0
        private void MenuItemOpen_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.InitialDirectory = Application.ExecutablePath;
            openFile.Filter           =
                "rtf files (*.rtf)|*.rtf|" +
                "txt files (*.txt)|*.txt|" +
                "Revit project files(*.rvt)| *.rvt |" +
                "Revit family files(*.rfa)|*.rfa |" +
                "Revit family template files(*.rft) | *.rft |" +
                "All files(=.=) | *.* ";
            openFile.FilterIndex      = 1;
            openFile.RestoreDirectory = true;

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string fullName = openFile.FileName;
                string fileName = Path.GetFileName(fullName);

                if (FindDocument(fileName) != null)
                {
                    MessageBox.Show("The document: " + fileName + " has already opened!");
                    return;
                }

                Doc Doc = new Doc();
                Doc.Text = fileName;
                if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
                {
                    Doc.MdiParent = this;
                    Doc.Show();
                }
                else
                {
                    Doc.Show(dockPanel);
                }
                try
                {
                    Doc.FileName = fullName;
                }
                catch (Exception exception)
                {
                    Doc.Close();
                    MessageBox.Show(exception.Message);
                }
            }
        }
Example #3
0
        private void menuItemOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.InitialDirectory = Application.ExecutablePath;
            openFile.Filter           = "cpc files (*.cpc)|*.cpc";
            openFile.FilterIndex      = 1;
            openFile.RestoreDirectory = true;

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string fullName = openFile.FileName;
                string fileName = Path.GetFileName(fullName);

                if (FindDocument(fileName) != null)
                {
                    MessageBox.Show("Le document: " + fileName + " est déjà ouvert !");
                    return;
                }

                Doc dummyDoc = new Doc();
                dummyDoc.Text = fileName;
                if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
                {
                    dummyDoc.MdiParent = this;
                    dummyDoc.Show();
                }
                else
                {
                    dummyDoc.Show(dockPanel);
                }
                try
                {
                    dummyDoc.FileName = fullName;
                }
                catch (Exception exception)
                {
                    dummyDoc.Close();
                    MessageBox.Show(exception.Message);
                }
            }
        }
Example #4
0
        public override bool Update()
        {
            if (Doc == null)
            {
                return(false);
            }
            var wordDoc  = (WordprocessingDocument)Doc;
            var mainPart = wordDoc.MainDocumentPart;

            mainPart.Document.Save();
            foreach (var f in mainPart.FooterParts)
            {
                f.Footer.Save();
            }
            foreach (var h in mainPart.HeaderParts)
            {
                h.Header.Save();
            }
            Doc.Close();
            return(true);
        }
Example #5
0
 /// <summary>
 /// Fecha o documento
 /// </summary>
 public void Close()
 {
     contentByte.Stroke();
     Doc.Close();
 }
Example #6
0
        private void MenuItemOpen_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.InitialDirectory = Application.ExecutablePath;
            openFile.Filter           =
                "china yupeng (*.cpf)|*.cpf|" +
                "China Yupeng family files (*.cyf)|*.cyf|" +

                "Autodesk Max family template files(*.max)|*.max|" +
                "Autodesk max family template files(*.obj)|*.obj|" +
                "Autodesk CAD family template files(*.dwg)|*.dwg|" +
                "Autodesk CAD family template files(*.dxf)|*.dxf|" +

                "Revit project files(*.rvt)|*.rvt|" +
                "Revit family files(*.rfa)|*.rfa|" +
                "Revit family template files(*.rft)|*.rft|" +
                "rtf files (*.rtf)|*.rtf|" +
                "txt files (*.txt)|*.txt|" +

                "SolidWork family template files(*.stl)|*.stl|" +
                "Pepakura designer family template files(*.PDO)|*.PDO|" +
                "Adobe family template files(*.pdf)|*.pdf|" +

                ///"预留"+
                ///"pdg"+
                ///
                ///

                "All files(=.=) | *.* ";
            openFile.FilterIndex      = 1;
            openFile.RestoreDirectory = true;

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string fullName = openFile.FileName;
                string fileName = Path.GetFileName(fullName);

                if (FindDocument(fileName) != null)
                {
                    MessageBox.Show("The document: " + fileName + " has already opened!");
                    return;
                }

                Doc Doc = new Doc();
                Doc.Text = fileName;
                if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
                {
                    Doc.MdiParent = this;
                    Doc.Show();
                }
                else
                {
                    Doc.Show(dockPanel);
                }
                try
                {
                    Doc.FileName = fullName;
                }
                catch (Exception exception)
                {
                    Doc.Close();
                    MessageBox.Show(exception.Message);
                }
            }
        }
Example #7
0
        public bool Export(List <OverdueModel> overdues)
        {
            try
            {
                //清空导出文件夹
                DirectoryInfo    dir      = new DirectoryInfo(GlobalVariables.OverduePDFExportPath);
                FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();  //返回目录中所有文件和子目录
                foreach (FileSystemInfo i in fileinfo)
                {
                    if (i is DirectoryInfo)            //判断是否文件夹
                    {
                        DirectoryInfo subdir = new DirectoryInfo(i.FullName);
                        subdir.Delete(true);          //删除子目录和文件
                    }
                    else
                    {
                        File.Delete(i.FullName);      //删除指定文件
                    }
                }

                string exportFile = GlobalVariables.OverduePDFExportPath + "催费提醒_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf";
                PdfWriter.GetInstance(Doc, new FileStream(exportFile, FileMode.Create));
                Doc.Open();

                PdfPTable table = new PdfPTable(TotalCols);
                AddTitle("缴费提醒", table);
                AddSubTitle(string.Format("({0})", DateTime.Now.ToString("yyyy.MM.dd")), table);
                AddBlank(Font_Title, table);


                PdfPCell cell_nameHeader  = CreateCellWithBottomBorder("姓名", Font_TableHeader, 2);
                PdfPCell cell_classHeader = CreateCellWithBottomBorder("班级", Font_TableHeader, 4);
                PdfPCell cell_dateHeader  = CreateCellWithBottomBorder("到期日期", Font_TableHeader, 3);
                PdfPCell cell_moneyHeader = CreateCellWithBottomBorder("续缴金额", Font_TableHeader, 2);

                table.AddCell(cell_nameHeader);
                table.AddCell(cell_classHeader);
                table.AddCell(cell_dateHeader);
                table.AddCell(cell_moneyHeader);

                foreach (OverdueModel itemn in overdues)
                {
                    PdfPCell cell_regularName  = CreateCellWithNoBorder(itemn.TraineeName, Font_TableCell, 2);
                    PdfPCell cell_regularClass = CreateCellWithNoBorder(itemn.ClassName, Font_TableCell, 4);
                    PdfPCell cell_regularDate  = CreateCellWithNoBorder(itemn.OverdueDate.ToString("yyyy年MM月dd日"), Font_TableCell, 3);
                    PdfPCell cell_regularMoney = CreateCellWithNoBorder(itemn.RenewAmount.ToString(), Font_TableCell, 2);

                    table.AddCell(cell_regularName);
                    table.AddCell(cell_regularClass);
                    table.AddCell(cell_regularDate);
                    table.AddCell(cell_regularMoney);
                }

                Doc.Add(table);
                Doc.Close();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }