• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ApplicationClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ApplicationClass的典型用法代码示例。如果您正苦于以下问题:C# ApplicationClass类的具体用法?C# ApplicationClass怎么用?C# ApplicationClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ApplicationClass类属于命名空间,在下文中一共展示了ApplicationClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExportToExcel

        public void ExportToExcel(DataGridView grid,string r_id,string time)
        {
            ApplicationClass Excel = new ApplicationClass();
            XlReferenceStyle RefStyle = Excel.ReferenceStyle;
            Excel.Visible = true;
            Workbook wb = null;
            String TemplatePath = System.Windows.Forms.Application.StartupPath + @"\Отчет"+r_id+".xlt";
            try
            {
                wb = Excel.Workbooks.Add(TemplatePath); // !!!
            }
            catch (System.Exception ex)
            {
                throw new Exception("Не удалось загрузить шаблон для экспорта " + TemplatePath + "\n" + ex.Message);
            }
            Worksheet ws = wb.Worksheets.get_Item(1) as Worksheet;

            ws.Cells[20, 3] = time;

            for (int j = 0; j < grid.Columns.Count; ++j)
            {
                //(ws.Cells[1+20, j + 1+2] as Range).Value2 = grid.Columns[j].HeaderText;
                for (int i = 0; i < grid.Rows.Count; ++i)
                {
                    object Val = grid.Rows[i].Cells[j].Value;
                    if (Val != null)
                        (ws.Cells[i + 2+20, j + 1+2] as Range).Value2 = Val.ToString();
                }
            }
               // ws.Columns.EntireColumn.AutoFit();
            Excel.ReferenceStyle = RefStyle;
            ReleaseExcel(Excel as Object);
        }
开发者ID:tatar1nro,项目名称:KKM_Trash,代码行数:33,代码来源:ExportXLS.cs


示例2: ConvertDocument

        void ConvertDocument(Guid g, string fileName)
        {
            object m = System.Reflection.Missing.Value;
            object oldFileName = (object)fileName;
            object readOnly = (object)false;
            ApplicationClass ac = null;
            System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
            try
            {

                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                // First, create a new Microsoft.Office.Interop.Word.ApplicationClass.
                ac = new ApplicationClass();

                // Now we open the document.
                Presentation doc = ac.Presentations.Open(fileName , Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);

                // Create a temp file to save the HTML file to.
                string tempFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), g.ToString() + ".html");
                // Cast these items to object.  The methods we're calling
                // only take object types in their method parameters.

                // Save the file.
                doc.SaveAs(tempFileName, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, Microsoft.Office.Core.MsoTriState.msoFalse);

            }
            finally
            {
                // Make sure we close the application class.
                if (ac != null)
                    ac.Quit();
                System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;
            }
        }
开发者ID:RevolutionSmythe,项目名称:cairoshell,代码行数:34,代码来源:PowerPointPreview.cs


示例3: SaveExcelFile

        public static void SaveExcelFile(string fileName, string tempFileName,string[,] contents, int startColumn, int startRow)
        {
            try
            {
                excelApp = new ApplicationClass();
                Workbooks myWorkBooks = excelApp.Workbooks;
                myWorkBooks.Open(tempFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                Sheets sheets = excelApp.Sheets;
                mySheet1 = (Worksheet)sheets[1];
                mySheet1.Activate();

                //写入测试信息
                Range range1 = mySheet1.get_Range(mySheet1.Cells[startRow, startColumn], mySheet1.Cells[contents.GetLength(0)+startRow-1,contents.GetLength(1)+startColumn-1]);
                range1.Value2 = contents;
                mySheet1.SaveAs(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                myWorkBooks.Close();
                excelApp.Quit();
                excelApp = null;
            }
            catch (Exception ee)
            {

                throw ee;
            }
        }
开发者ID:dewade2003,项目名称:apple,代码行数:25,代码来源:ExcelUtil.cs


示例4: getTestSpecificationDocTOC

        public Dictionary<string, List<TermContainer>> getTestSpecificationDocTOC(Document doc, ApplicationClass app)
        {
            generateTOC(doc, app);
            Range tocRange = doc.TablesOfContents[1].Range;
            string[] tocContents = delimiterTOC(tocRange.Text);

            Dictionary<string, List<TermContainer>> dict = new Dictionary<string, List<TermContainer>>();
            string chapter = "";

            foreach (string s in tocContents)
            {
                if (isLevel1(s))
                {
                    chapter = s;
                    dict.Add(s, new List<TermContainer>());
                }
                else
                {
                    if (isLevel2(s))
                    {
                        TermContainer term = new TermContainer("", s, null);
                        dict[chapter].Add(term);
                    }
                }

            }
            return dict;
        }
开发者ID:v02zk,项目名称:Mycoding,代码行数:28,代码来源:HandleDocument.cs


示例5: EncryptExcelByPassword

    /// <summary>
    /// 
    /// </summary>
    /// <param name="UnEncryptFileName">Excel原始檔名</param>
    /// <param name="EncryptFileName">Excel加密後檔名</param>
    /// <param name="OpenExcelPassword">允許開啟密碼</param>
    /// <param name="WriteExcelPassword">允許編寫密碼</param>
    public static void EncryptExcelByPassword(string UnEncryptFileName, string EncryptFileName,
        string OpenExcelPassword, string WriteExcelPassword)
    {
        ApplicationClass xApp = new ApplicationClass();
        try
        {
            Workbook xBook = xApp.Workbooks.Open(UnEncryptFileName,
          Missing.Value, Missing.Value, Missing.Value, Missing.Value,
          Missing.Value, Missing.Value, Missing.Value, Missing.Value,
          Missing.Value, Missing.Value, Missing.Value, Missing.Value);

            if (File.Exists(EncryptFileName)) File.Delete(EncryptFileName);

            xBook.SaveAs(EncryptFileName, XlFileFormat.xlExcel12
                , OpenExcelPassword, WriteExcelPassword, Missing.Value,
              Missing.Value, XlSaveAsAccessMode.xlNoChange, Missing.Value,
              Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            xBook.Save();
            xBook.Close();
            xBook = null;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            xApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xApp);
            xApp = null;
        }
        GC.Collect();
    }
开发者ID:AdamsChao,项目名称:netdb-localdev-proj,代码行数:40,代码来源:ExcelEncrypt.cs


示例6: x

 private void x()
 {
     Excel.Application app = new ApplicationClass();
     try
     {
         //app.ActivePrinter = "Acrobat Distiller";
         Workbooks workBooks = app.Workbooks;
         Workbook workBook = (Workbook )workBooks.GetType().InvokeMember("Open",BindingFlags.InvokeMethod,null,workBooks,new object[]{@"C:\Documents and Settings\raghunandanr\Desktop\Template Format for PDF Transcription1.xls"});
         workBook.PrintOut(1,Type.Missing,1,false,"Acrobat Distiller",true,true,@"C:\Documents and Settings\raghunandanr\Desktop\Template Format for PDF Transcription1.ps");
         workBook.Close(false,Type.Missing,Type.Missing);
         PdfDistiller dist = new PdfDistillerClass();
         //dist.bSpoolJobs = 1;
         dist.bShowWindow = 0;
         dist.OnJobFail += new _PdfEvents_OnJobFailEventHandler(Fail);
         dist.FileToPDF(@"C:\Documents and Settings\raghunandanr\Desktop\Template Format for PDF Transcription1.ps",null,null);
         Marshal.ReleaseComObject(dist);
         dist=null;
     }
     catch(Exception ex){Response.Write(ex.Message);}
     finally
     {
         app.Quit();
         Marshal.ReleaseComObject(app);
         app = null;
         GC.Collect();
         GC.WaitForPendingFinalizers();
     }
 }
开发者ID:rags,项目名称:playground,代码行数:28,代码来源:frmExcelToPdf.aspx.cs


示例7: GetSheetNames

        public static List<string> GetSheetNames(string fileName)
        {
            ApplicationClass excelapp = new ApplicationClass();
            RecentFile re = excelapp.RecentFiles.Add(fileName);// nhan ve file vua chon de xu ly
            List<string> lstSheet = new List<string>();
            try
            {
                excelapp.Visible = false;
                Workbook excelWorkbook = re.Open();// mở ra và có thể truy xuất các sheet
                if (excelWorkbook.Sheets.Count > 0)
                {
                    Worksheet excelWorkSheet;
                    for (int i = 1; i <= excelWorkbook.Sheets.Count; i++)
                    {
                        excelWorkSheet = (Worksheet)excelWorkbook.Sheets[i];
                        lstSheet.Add(excelWorkSheet.Name);
                    }
                    excelWorkSheet = null;
                }
                excelWorkbook = null;
                re.Application.Quit();
                excelapp.Quit();// thoat khoi chuong trinh excel.exe trong he thong

            }
            catch (Exception) { }
            return lstSheet;
        }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:27,代码来源:ExcelSupport.cs


示例8: DataTableToWorkBook

 public static Workbook DataTableToWorkBook(System.Data.DataTable dt, string[] Cells)
 {
     if (dt.Columns.Count < 1)
     {
         throw new Exception("_Excel.DataTableToWorkBook 方法提供的 DataTable 参数找不到任何可用的列。");
     }
     Application application = new ApplicationClass();
     Workbook workbook = application.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
     Worksheet worksheet = (Worksheet) workbook.Worksheets[1];
     long count = dt.Rows.Count;
     long num2 = 0L;
     for (int i = 0; i < dt.Columns.Count; i++)
     {
         if (((Cells != null) && (Cells.Length > i)) && !string.IsNullOrEmpty(Cells[i]))
         {
             worksheet.Cells[1, i + 1] = Cells[i].Trim();
         }
         else
         {
             worksheet.Cells[1, i + 1] = dt.Columns[i].ColumnName;
         }
         Microsoft.Office.Interop.Excel.Range range1 = (Microsoft.Office.Interop.Excel.Range) worksheet.Cells[1, i + 1];
     }
     for (int j = 0; j < dt.Rows.Count; j++)
     {
         for (int k = 0; k < dt.Columns.Count; k++)
         {
             worksheet.Cells[j + 2, k + 1] = dt.Rows[j][k];
             Microsoft.Office.Interop.Excel.Range range2 = (Microsoft.Office.Interop.Excel.Range) worksheet.Cells[j + 2, k + 1];
         }
         num2 += 1L;
         float single1 = ((float) (100L * num2)) / ((float) count);
     }
     return workbook;
 }
开发者ID:NoobSkie,项目名称:taobao-shop-helper,代码行数:35,代码来源:_Excel.cs


示例9: Bai2_Load

        private void Bai2_Load(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Word.ApplicationClass wordApplication = new ApplicationClass();
            object o_nullobject = System.Reflection.Missing.Value;
            object o_filePath = System.IO.Directory.GetCurrentDirectory() + "\\Resources\\PhepNhan.doc";
            object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
            object o_encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
            object o_endings = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
            object o_Readonly = true;
            Microsoft.Office.Interop.Word.Document doc = wordApplication.Documents.Open(ref o_filePath,
            ref o_nullobject, ref o_Readonly, ref o_nullobject, ref o_nullobject, ref o_nullobject,
            ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
            ref o_nullobject, ref o_nullobject);

            doc.ActiveWindow.Selection.WholeStory();

            doc.ActiveWindow.Selection.Copy();

            IDataObject data = Clipboard.GetDataObject();

            txtLyThuyet.Text = data.GetData(DataFormats.UnicodeText).ToString();

            doc.Close(ref o_nullobject, ref o_nullobject, ref o_nullobject);
            wordApplication.Quit(ref o_nullobject, ref o_nullobject, ref o_nullobject);

            PhepTinhDAO phepTinhDAO = new PhepTinhDAO();
            PhepTinhDTO phepTinhDTO = new PhepTinhDTO();

            arrPhepTinh = phepTinhDAO.getPhepTinhNhan();
            sizeOfXML = arrPhepTinh.Count;
            phepTinhDTO = (PhepTinhDTO)arrPhepTinh[0];
            tbTemp1.Text = phepTinhDTO.SoThuNhat.ToString();
            tbTemp2.Text = phepTinhDTO.SoThuHai.ToString();
        }
开发者ID:ahmedelsayed27,项目名称:xdpm-hk2-2010,代码行数:34,代码来源:Bai2.cs


示例10: InstrumentationCanBeAttachedToInstrumentationProviderWhenInstanceNameIsPresent

        public void InstrumentationCanBeAttachedToInstrumentationProviderWhenInstanceNameIsPresent()
        {
            ApplicationClass applicationObject = new ApplicationClass();
            strategy.AttachInstrumentation("InstanceName", applicationObject, instrumentationConfigurationSource, reflectionCache);

            Assert.IsTrue(((InstrumentationProvider) (applicationObject.GetInstrumentationEventProvider())).IsWired);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:7,代码来源:InstrumentationAttachmentStrategyFixture.cs


示例11: ConvertDocument

 void ConvertDocument(Guid g, string fileName)
 {
     object m = System.Reflection.Missing.Value;
     object oldFileName = (object)fileName;
     object readOnly = (object)false;
     ApplicationClass ac = null;
     try
     {
         // First, create a new Microsoft.Office.Interop.Word.ApplicationClass.
         ac = new ApplicationClass();
         // Now we open the document.
         Document doc = ac.Documents.Open(ref oldFileName, ref m, ref readOnly,
             ref m, ref m, ref m, ref m, ref m, ref m, ref m,
             ref m, ref m, ref m, ref m, ref m, ref m);
         // Create a temp file to save the HTML file to.
         string tempFileName =Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + g.ToString() + ".html";
         // Cast these items to object.  The methods we're calling
         // only take object types in their method parameters.
         object newFileName = (object)tempFileName;
         // We will be saving this file as HTML format.
         object fileType = (object)WdSaveFormat.wdFormatHTML;
         // Save the file.
         doc.SaveAs(ref newFileName, ref fileType,
             ref m, ref m, ref m, ref m, ref m, ref m, ref m,
             ref m, ref m, ref m, ref m, ref m, ref m, ref m);
     }
     finally
     {
         // Make sure we close the application class.
         if (ac != null)
             ac.Quit(ref readOnly, ref m, ref m);
     }
 }
开发者ID:RevolutionSmythe,项目名称:cairoshell,代码行数:33,代码来源:WordPreview.cs


示例12: Read

        private static Worksheet mySheet1; //工作簿1

        #endregion Fields

        #region Methods

        public static List<List<string>> Read(string fileName,int columnCount,int startRowIndex)
        {
            List<List<string>> textList = new List<List<string>>();
            excelApp = new ApplicationClass();
            Workbooks myWorkBooks = excelApp.Workbooks;
            myWorkBooks.Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
            Sheets sheets = excelApp.Sheets;
            mySheet1 = (Worksheet)sheets[1];
            int rowCount = mySheet1.UsedRange.Rows.Count;
            if (rowCount != 0)
            {
                for (int i = startRowIndex; i <= rowCount; i++)
                {
                    string name = ((Range)mySheet1.Cells[i, 2]).Text.ToString();

                    if (name != "") {
                        List<string> list = new List<string>();
                        list.Add((i-startRowIndex+1).ToString());
                        for (int j = 0; j < columnCount; j++)
                        {
                            list.Add(((Range)mySheet1.Cells[i, j + 1]).Text.ToString());
                        }
                        textList.Add(list);
                    }
                }
            }
            myWorkBooks.Close();
            excelApp.Quit();
            excelApp = null;
            return textList;
        }
开发者ID:dewade2003,项目名称:apple,代码行数:37,代码来源:ExcelUtil.cs


示例13: WriteToNewWordFile

        public static void WriteToNewWordFile(string path, string text)
        {
            ApplicationClass wordApp = new ApplicationClass();


            object nullobj = Missing.Value;
            object file = path;
            object fileFormat = WdSaveFormat.wdFormatHTML;
            object encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
            

            FileUtils.WriteAllText(path, text);

            var doc = wordApp.Documents.Add(ref nullobj, ref nullobj, ref nullobj, ref nullobj);

            if (text.IsNull())// If file open in first time save as word html
            {
                doc.SaveAs(ref file, ref fileFormat, ref nullobj, ref nullobj,
                    ref nullobj, ref nullobj, ref nullobj, ref nullobj,
                    ref nullobj, ref nullobj, ref nullobj,
                    /*Encoding*/ref encoding, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
            }
            (doc as _Document).Close(ref nullobj, ref nullobj, ref nullobj);
            wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
        }
开发者ID:supermuk,项目名称:iudico,代码行数:25,代码来源:CodeSnippet.cs


示例14: Word2Pdf

 public static void Word2Pdf(string path, string savepath)
 {
     var word = new ApplicationClass();
     var wordType = word.GetType();
     var docs = word.Documents;
     var docsType = docs.GetType();
     var doc = (Document) docsType.InvokeMember(
         "Open",
         BindingFlags.InvokeMethod,
         null,
         docs,
         new[] {(object)path, true, true});
     var docType = doc.GetType();
     docType.InvokeMember(
         "SaveAs",
         BindingFlags.InvokeMethod,
         null,
         doc,
         new[] {(object) savepath, WdSaveFormat.wdFormatPDF});
     docType.InvokeMember(
         "Close",
         BindingFlags.InvokeMethod,
         null,
         doc,
         new object[] {WdSaveOptions.wdDoNotSaveChanges});
     wordType.InvokeMember(
         "Quit",
         BindingFlags.InvokeMethod,
         null,
         word,
         null);
 }
开发者ID:jinghang,项目名称:DevHelper,代码行数:32,代码来源:Program.cs


示例15: Bai1_Load

        private void Bai1_Load(object sender, EventArgs e)
        {
            currentIndex=0;
            So5ChuSoDAO so5ChuSoDAO = new So5ChuSoDAO();
            So5ChuSoDTO so5ChuSoDTO = null;

            arrSo5ChuSo = so5ChuSoDAO.getSo5ChuSo();
            sizeOfXML = arrSo5ChuSo.Count;
            so5ChuSoDTO = (So5ChuSoDTO)arrSo5ChuSo[0];
            lbDocSo.Text = so5ChuSoDTO.Text;
            currentResult = so5ChuSoDTO.Number;

            Microsoft.Office.Interop.Word.ApplicationClass wordApplication = new ApplicationClass();
            object o_nullobject = System.Reflection.Missing.Value;
            object o_filePath = System.IO.Directory.GetCurrentDirectory() + "\\Resources\\CacSoCo5ChuSo.doc";
            object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
            object o_encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
            object o_endings = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
            object o_Readonly = true;
            Microsoft.Office.Interop.Word.Document doc = wordApplication.Documents.Open(ref o_filePath,
            ref o_nullobject, ref o_Readonly, ref o_nullobject, ref o_nullobject, ref o_nullobject,
            ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
            ref o_nullobject, ref o_nullobject);

            doc.ActiveWindow.Selection.WholeStory();

            doc.ActiveWindow.Selection.Copy();

            IDataObject data = Clipboard.GetDataObject();

            txtLyThuyet.Text = data.GetData(DataFormats.UnicodeText).ToString();

            doc.Close(ref o_nullobject, ref o_nullobject, ref o_nullobject);
            wordApplication.Quit(ref o_nullobject, ref o_nullobject, ref o_nullobject);
        }
开发者ID:ahmedelsayed27,项目名称:xdpm-hk2-2010,代码行数:35,代码来源:Bai1.cs


示例16: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            var from = DateTimePickerFrom.Value;
            var to = DateTimePickerTo.Value;

            if(from >= to)
            {
                MessageBox.Show("To date must be later than From date", "Error");
                return;
            }

            var fridays = new List<DateTime>();
            var saturdays = new List<DateTime>();
            for (; from <= to; from.AddDays(1))
            {
                switch (from.DayOfWeek)
                {
                    case DayOfWeek.Friday:
                        fridays.Add(from);
                        break;
                    case DayOfWeek.Saturday:
                        saturdays.Add(from);
                        break;
                }
            }

            var excel = new ApplicationClass();
        }
开发者ID:felixpp,项目名称:Scheduler2P,代码行数:28,代码来源:SchedulerForm.cs


示例17: MakeGraphs

 public void MakeGraphs(string dir, bool includePearson, bool includeSpearman)
 {
     Application xlApp = new ApplicationClass();
     Workbook xlWorkBook = xlApp.Workbooks.Add(MisValue);
     List<Worksheet> workSheets = PopulateWorkSheets(xlWorkBook, includePearson, includeSpearman);
     dir = SaveFile(dir, xlWorkBook);
     ReleaseResources(xlApp, xlWorkBook, workSheets);
 }
开发者ID:mgevers-vintageSoftware,项目名称:MultiCorrelation,代码行数:8,代码来源:CorrelationCalc.cs


示例18: ToWordDoc

 private Document oDoc; // a reference to the document
 public ToWordDoc()
 {
     //
     // TODO: 在此处添加构造函数逻辑
     //
     // activate the interface with the COM object of Microsoft Word
     oWordApplic = new ApplicationClass();
 }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:9,代码来源:ToWordDoc.cs


示例19: Convert

        public int Convert(string sourcePath, string targetPath)
        {
            if (!File.Exists(sourcePath))
            {
                return ErrorMessages.FileNotExist;
            }
            XlFixedFormatType targetType = XlFixedFormatType.xlTypePDF;

            object missing = Type.Missing;
            ApplicationClass application = new ApplicationClass(); ;
            Workbook workBook = null;
            try
            {
                workBook = application.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing,
                                                      missing, missing, missing, missing, missing, missing, missing, missing, missing);
                //设置格式,导出成PDF
                Worksheet sheet = (Worksheet)workBook.Worksheets[1]; //下载从1开始
                //把sheet设置成横向
                sheet.PageSetup.Orientation = XlPageOrientation.xlLandscape;
                //可以设置sheet页的其他相关设置,不列举
                sheet.ExportAsFixedFormat(targetType,
                                            targetPath,
                                            XlFixedFormatQuality.xlQualityStandard,
                                            true,
                                            false,
                                            missing,
                                            missing,
                                            missing,
                                            missing);

                return ErrorMessages.ConvertSuccess;
            }
            catch (COMException ex)
            {
                _logger.Error(ex.StackTrace);
                _logger.Error(ex.Message);
                return ErrorMessages.OfficeToPdfUninstall;
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return ErrorMessages.ConvertFailed;
            }
            finally
            {
                if (workBook != null)
                {
                    workBook.Close(true, missing, missing);
                }
                if (application != null)
                {
                    application.Quit();
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
开发者ID:ideayapai,项目名称:docviewer,代码行数:57,代码来源:ExcelToPdfConverter.cs


示例20: openDocument

        public Document openDocument(string filepath,ApplicationClass word)
        {
            Object filename = filepath;

            return word.Documents.Open(ref filename, ref unknow,
                        ref unknow, ref unknow, ref unknow, ref unknow,
                       ref unknow, ref unknow, ref unknow, ref unknow, ref unknow,
                       ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
        }
开发者ID:v02zk,项目名称:Mycoding,代码行数:9,代码来源:HandleDocument.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ApplicationConfiguration类代码示例发布时间:2022-05-24
下一篇:
C# Application类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap