C#呼叫wps

費勁_奮進發表於2014-05-13

private void RunWps_Click(object sender, EventArgs e)
        {

            object myMissing = System.Reflection.Missing.Value;
            WPS.Application WpsApp = new WPS.ApplicationClass();
            WpsApp.Visible = true;
            WpsApp.WindowState = WPS.WpsWindowState.wpsWindowStateMaximize;
            WPS.Document WpsDoc = WpsApp.Documents.Add(ref myMissing, false, 1, true);
            WpsDoc.Content.Text = "Hello World!";
            WPS.Range myRange = WpsDoc.Range(0, 0);
            WpsDoc.Paragraphs.Add(myRange);
            WpsDoc.Range(0,0).Select();
            WpsApp.Selection.Text = "歡迎你學習C#呼叫WPS";
        }

C#呼叫WPS ET 轉換pdf

 

先安裝WPS

然後新增引用安裝目錄下的etapp.dll


C#呼叫wps  

2013-01-13 15:05:09|  分類: .net |  標籤:wps   |舉報 |字號 訂閱

private void RunWps_Click(object sender, EventArgs e)
        {

            object myMissing = System.Reflection.Missing.Value;
            WPS.Application WpsApp = new WPS.ApplicationClass();
            WpsApp.Visible = true;
            WpsApp.WindowState = WPS.WpsWindowState.wpsWindowStateMaximize;
            WPS.Document WpsDoc = WpsApp.Documents.Add(ref myMissing, false, 1, true);
            WpsDoc.Content.Text = "Hello World!";
            WPS.Range myRange = WpsDoc.Range(0, 0);
            WpsDoc.Paragraphs.Add(myRange);
            WpsDoc.Range(0,0).Select();
            WpsApp.Selection.Text = "歡迎你學習C#呼叫WPS";
        }

 

C#呼叫WPS ET 轉換pdf

 

先安裝WPS

然後新增引用安裝目錄下的etapp.dll

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Collections;
using ET;
namespace ExcelToPdf
{
    public partial class Form1 : Form
    {
        int ifsucess = 0;
        int iffail = 0;
        int allcount = 0;
        int num = 0;
        public Form1()
        {
            InitializeComponent();
        }

public void ConvertExcelToPDF(string xlspath,string pdfpath)
        {
            try
            {              
                object type = System.Reflection.Missing.Value;
                ET.ApplicationClass application = null;
                ET.workbook book = null;               
                try
                {
                    application = new ET.ApplicationClass();
                    book = (ET.workbook)application.Workbooks.Open(xlspath, type, type, type, type, type, type, type, type, type, type, type, type);
                    book.ExportPdf(pdfpath, "", "");  //this.GetFilePath(path)是獲取檔案路徑+檔名(不含字尾)
                }
                catch(Exception ex)
                {
               

相關文章