具体描述了运用Edraw Office Viewer Component为WPF应用长须嵌入MS Word,Excel以及Power Point的方法。

打开Visual Studio,并创建一个新的WPF应用程序。

右键单击WpfApplication1 Solution。 然后单击Add添加菜单,并点击User Control…

wpf的项目中将会出现一个新窗口。在Solution面板双击UserControl1.CS。

打开Toolbox面板,然后单击Choose Items…。

在弹出的Choose Toolbox Items选择工具箱项目对话框中,选择Edraw Office Viewer Component组件然后单击Ok。

Edraw Office Viewer Component组件就已经被添加到Toolbox工具箱中添加工具箱的General选项卡中。之后将它拖放到UserControl窗口。

这个AxEDofficeLib和EDOfficeLib将通过Visual Studio向导被添加到解决方案中。

键入以下的c#代码,打开一个word文档,并保护该Word文档不被修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WpfApplication1
{
public partial  class  UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public void  Open()
{
axEDOffice1.OpenFileDialog();
}
public void  Protect()
{
if (axEDOffice1.GetCurrentProgID() == "Word.Application")
{
axEDOffice1.ProtectDoc(2);
}
}
public void  Print()
{
axEDOffice1.PrintPreview();
}
public void  Close()
{
axEDOffice1.ExitOfficeApp();
}
}
}

最后,您需要为UserControl编写一个主机窗口。切换到Windows1.xaml文件然后加入开放、保护、打印和关闭按钮,如下图所示:

添加如下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
public partial  class  Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void  Open_Click(object sender, RoutedEventArgs e)
{
_host.Open();
}
private void  Protect_Click(object sender, RoutedEventArgs e)
{
_host.Protect();
}
private void  Print_Click(object sender, RoutedEventArgs e)
{
_host.Print();
}
private void  Close_Click(object sender, RoutedEventArgs e)
{
_host.Close();
}
}
}

打开Configuration Manager配置管理器。改变 Active解决方案平台为x86选项。然后构建并运行。

Office Viewer Component组件支持所有版本MS Word。嵌入MS Excel或PowerPoint,Visio、项目到一个WPF应用程序中,您不必改变任何东西,只能调用Open方法,如下所示:

1
2
3
4
5
6
7
8
9
public void  Open()
{
//axEDOffice1.OpenFileDialog();
axEDOffice1.Open(sPath, "Word.Application");
axEDOffice1.Open(sPath, "Excel.Application");
axEDOffice1.Open(sPath, "PowerPoint.Application");
axEDOffice1.Open(sPath, "Visio.Application");
axEDOffice1.Open(sPath, "MSProject.Application");
}

运用Edraw为WPF应用程序嵌入Office文档的方法总结的更多相关文章

  1. WPF:将Office文档、任意类型文件嵌入到EXE可执行文件中

    原文:WPF:将Office文档.任意类型文件嵌入到EXE可执行文件中 版权声明:本文为博主原创文章,未经博主允许可以随意转载 https://blog.csdn.net/songqingwei198 ...

  2. WPF应用程序嵌入第三方exe

    把其它应用嵌入到C#窗口 源代码-CSDN下载 https://download.csdn.net/download/aiqinghee/10652732 WPF应用程序嵌入第三方exe - gao2 ...

  3. 使用WebDAV实现Office文档在线编辑

    Office的文档处理能力是非常强大的,但是它是本地资源,在Office Web App尚未成熟前,仍需要使用本地能力来进行文档编辑,可是现代的系统的主流却是B/S,所以在B/S中调用本地的Offic ...

  4. 海量Office文档搜索

    知识管理系统Data Solution研发日记之十 海量Office文档搜索   经过前面两篇文章的介绍,<分享制作精良的知识管理系统 博客备份程序 Site Rebuild>和<分 ...

  5. Office文档在线编辑的实现之二

    讲述了如何通过iis的webdav支持实现客户端的office直接编辑服务器上的文件,本篇将讲解如何实现客户端的office直接编辑数据库中的二进制形式保存的office文件. 实现的关键:模拟IIS ...

  6. 在线office文档编辑NTKO使用心得

    目录 前言 什么是ntko 准备工作 实战演练 总结 一.前言 Web开发中经常需要用到在线处理office文档的功能,现在市面上有一些常用的Web页面调用显示Office的控件技术,用起来很方便.有 ...

  7. 在线预览-Java 使用 Print2Flash 实现Office文档在线阅读

    近期项目上遇到一个需求是用户上传的文档进行在线浏览,之前有过一篇使用 OpenOffice 将 word 转换成 html 页面进行展示的.现在介绍一个新的工具那就是 Print2Flash .    ...

  8. NTKO OFFICE文档控件

    目录 前言 什么是ntko 准备工作 实战演练 总结 一.前言 Web开发中经常需要用到在线处理office文档的功能,现在市面上有一些常用的Web页面调用显示Office的控件技术,用起来很方便. ...

  9. 转:C#实现office文档转换为PDF或xps的一些方法

    代码支持任意office格式 需要安装office 2007 还有一个office2007的插件OfficeSaveAsPDFandXPS 下载地址 [url]http://www.microsoft ...

随机推荐

  1. selenium python 时间控件的输入问题

    对于时间的选择问题,查到的大部分为两种情况: 1.存在readonly属性的 2.没有readonly属性的 可直接赋值send_keys() 测试用例中刚好是没有readonly属性的 且定位不到弹 ...

  2. origin横纵坐标颠倒

    origin默认是只能多个纵坐标,不能多个横坐标,所以这种情况只能先作成多个Y,然后像这样exchange一下.

  3. Karma+Jasmine测试环境搭建

    1.如果你还没安装node的话,去这里下载:http://nodejs.cn/download/,选择跟你电脑匹配的并进行安装,一路next下来就行,路径最好改成自己让自己舒服的,默认的路径可能会很让 ...

  4. VBS虚拟键盘十六进制列表

    Set WshShell=WScript.CreateObject("WScript.Shell") '打开我的电脑WshShell.Sendkeys chr(&h88b6 ...

  5. 在python3.5中pip安装scrapy,遇到 error: Microsoft Visual C++ 14.0 is required

    本来在python3.5中安装scrapy一路顺畅(pip install scrapy),中间遇到一个 error: Microsoft Visual C++ 14.0 is required. x ...

  6. 2.在centos7虚拟机搭建nginx网站

    1.nginx配置目录 cd /etc/nginx/conf.d/ 添加 vi www.18cat.conf server{ listen 80; server_name www.18cat.com; ...

  7. 认识CSS中css的三大特性:层叠性、继承性以及优先级

    前端之HTML.CSS(四) CSS CSS三大特性 层叠性:多种样式的叠加,一个属性通过两个选择器设置在同一个元素上,后一个样式会把前一个样式层叠(覆盖).层叠性的两种情况:第一种样式冲突时,后样式 ...

  8. CNN Advanced

    from sys import path path.append('/home/ustcjing/models/tutorials/image/cifar10/') import cifar10,ci ...

  9. PIE SDK专题制图打开模板

    1.    功能简介 在PIE SDK中,所有的制图元素.视图范围以及排版等都可以保存成一个模板,以供多次重复使用.使用时只需要打开该模板,加载相应数据,就可以直接出图了,省去了重复制作图幅的麻烦,方 ...

  10. my32_ error 1872 Slave failed to initialize relay log info structure from the repository

    重启了实例后,slave进程无法开启 Last_SQL_Errno: Last_SQL_Error: Slave failed to initialize relay log info structu ...