主要介绍asp.net调用visio com的基本用法,主要用于控制visio图形背景色,文字显示等。

主要步骤:

1、 项目中引用COM组件,找到Mircosoft Visio 14 Type Library(根据Visio版本,14可能有所不同)。

2、 项目编译通常会报错:无法嵌入互操作类型“Microsoft.Office.Interop.Visio.ApplicationClass”。请改用适用的接口。此时将Microsoft.Office.Interop.Visio这个引用右键属性将嵌入互操作类型true改成false。

3、 下面代码完成Visio图中形状底色的改变和图形文字的修改(主要代码):

Document doc = null;

ApplicationClass app = new ApplicationClass();//运行Visio应用程序

string currentPath = Server.MapPath("~/A.vsd ");//文件路径

doc = app.Documents.OpenEx(currentPath, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenCopy);//打开一个visio文件

Shape shape1 = doc.Pages[1].Shapes["Test"];//此处获取visio中指定名称的形状

shape1.Text = "Hello World";//形状文字修改

shape1.get_CellsU("FillPattern").ResultIU = 1;//设置 背景色时 需设置

shape1.get_CellsU("FillBkgnd").ResultIU = (double)VisDefaultColors.visDarkYellow;//背景色

doc.Close();//关闭打开的文件

app.Quit();//退出Visio应用程序

4、Visio中需打开开发者模式,这样才能给指定形状命名。

5、发布到服务器上需要配置相应的权限,可以参考Excel 组件服务权限配置。

最新文章

  1. 用Barcode生成条形码图片
  2. ubuntu为用户增加sudoer权限的两种方法
  3. java_easyui体系之DataGrid(1)[转]
  4. Java - 简单的对象排序 - Comparator
  5. 关灯游戏源码(iOS)
  6. 获取元素高度及定位js
  7. c#winform使用WebBrowser 大全[超长文转载]
  8. ContentProvider使用
  9. ISE综合后得到的RTL图如何与硬件对应起来,怎么知道每个element的功能
  10. linux 下的sublime
  11. Hadoop在linux下无法启动DataNode解决方法
  12. c++11 auto
  13. 最锋利的Visual Studio Web开发工具扩展:Web Essentials详解
  14. Python实现单词查询&文件查找
  15. arm swi 软中断 一例
  16. [转] vue&webpack多页面配置
  17. linux 命令 — archive
  18. [uboot] (第一章)uboot流程——概述
  19. nginx php
  20. 【python】安装py3-bencode 及小例程

热门文章

  1. PrettyProgressBar
  2. [AngularJS] Using the Angular scope $destroy event and method
  3. poj 2688 状态压缩dp解tsp
  4. SSD(固态硬盘)简介
  5. 果然还是SB了
  6. ios----protocol, optional ,delegate
  7. 基于MFC的Opengl实现动画
  8. 【Shell脚本学习21】Shell break和continue命令
  9. 社交分享:-canOpenURL: failed for URL: "weixin://app/*************/" - error: "This app is not allowed to query for scheme weixin"
  10. C语言中的内存压缩技术