具体描述了运用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. Nuclear Power Plant ZOJ - 3840 树形dp

    There are N (1 ≤ N ≤ 105) cities on land, and there are N - 1 wires connecting the cities. Therefore ...

  2. TX2 自制底板不识别USB

    目的:解决自制的底板无法识别USB,使能3个UART接口,使能3个SPI接口. Jetpack版本:Jetpack-3.1 虚拟机:ubuntu14.04 使用dtb文件夹下的文件替换刷机包../64 ...

  3. 数据库分库分表配置sharding-jdbc

    @Bean(name = "shardingDataSource", destroyMethod = "close") @Qualifier("sha ...

  4. Qt 学习之路 2(53):自定义拖放数据

    Qt 学习之路 2(53):自定义拖放数据 豆子  2013年5月26日  Qt 学习之路 2  13条评论上一章中,我们的例子使用系统提供的拖放对象QMimeData进行拖放数据的存储.比如使用QM ...

  5. POJ_1703 Find them, Catch them 【并查集】

    一.题面 POJ1703 二.分析 需要将并查集与矢量法则相结合.par数组用以记录父节点,rank用以记录与父节点的关系.如题意,有两种关系,设定0是属于同一个帮派,1表示不属于同一个帮派. 运用并 ...

  6. hdu1686 Oulipo kmp

    题目传送门 思路:kmp模板,稍微修改下 #include<bits/stdc++.h> #define clr(a,b) memset(a,b,sizeof(a)) using name ...

  7. web 前端提交方式

    1.get提交    如: <a href="actions/Student_Add?name=a&age=8">路径问题说明add</a>< ...

  8. MariaDB 密码,新用户添加

    修改root密码1.以root身份在终端登陆(必须)2.输入 mysqladmin -u root -p password ex后面的 ex 是要设置的密码3.回车后出现 Enter password ...

  9. [转] Emmet-前端开发神器

    [From] https://segmentfault.com/a/1190000007812543 Emmet是一款编辑器插件,支持多种编辑器支持.在前端开发中,Emmet 使用缩写语法快速编写 H ...

  10. UML-3-案例研究

    没有什么比恰当的举例更难的了.-----马克吐温