利用Visio导出组织结构图
来源:互联网 发布:世界征服者3mac下载 编辑:程序博客网 时间:2024/04/29 20:05
在做HR系统的时候,往往需要导出Visio格式的组织结构图。
以前很少接触Office的二次开发,这个东西足足搞了我一个礼拜,汗~~~~~
我的环境为Visio2003+VS2005
主要是利用OrgCWiz,这个Visio提供的接口,具体的参数请参考MS的网站
http://office.microsoft.com/zh-cn/visio/HA010774642052.aspx
个人认为http://visio.mvps.org/VBA.htm这个网站比较专业,很多关于Visio的资料可以参考一下
导出的代码很简单,主要为
Microsoft.Office.Interop.Visio.ApplicationClass _app = new ApplicationClass();
Microsoft.Office.Interop.Visio.Addon ac = _app.Addons.get_ItemU("OrgCWiz");
ac.Run("/S-INIT");
string commandargs = " ...............................";
ac.Run("/S-ARGSTR "+commandargs);
ac.Run("/S-RUN");
_app.ActiveDocument.SaveAsEx(destfile,6);
_app.Quit();
GC.Collect();
Microsoft.Office.Interop.Visio.Addon ac = _app.Addons.get_ItemU("OrgCWiz");
ac.Run("/S-INIT");
string commandargs = " ...............................";
ac.Run("/S-ARGSTR "+commandargs);
ac.Run("/S-RUN");
_app.ActiveDocument.SaveAsEx(destfile,6);
_app.Quit();
GC.Collect();
也可以参考http://www.cnblogs.com/invinboy/archive/2006/05/19/404725.html这篇文章
以下代码为设置文本框的背景色
Cell cell = shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillForegnd);
cell.FormulaU = "RGB(176,197,227)";
(short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillForegnd);
cell.FormulaU = "RGB(176,197,227)";
以下代码为设置Title(字体大小及颜色)
Shape shapeTitle = page.Drop(doc.Masters.get_ItemU("Title"), 6, 7.8);
shapeTitle.Text = "";
Cell cellTitle = shapeTitle.get_CellsSRC((short)VisSectionIndices.visSectionCharacter,
0, (short)VisCellIndices.visCharacterColor);
cellTitle.FormulaU = "RGB(153,0,51)";
shapeTitle.Characters.Text = "组织结构图";
shapeTitle.Characters.set_CharProps(
(short)VisCellIndices.visCharacterStyle,
(short)VisCellVals.visBold);
shapeTitle.Characters.set_CharProps((short)VisCellIndices.visCharacterSize, 24);
shapeTitle.Text = "";
Cell cellTitle = shapeTitle.get_CellsSRC((short)VisSectionIndices.visSectionCharacter,
0, (short)VisCellIndices.visCharacterColor);
cellTitle.FormulaU = "RGB(153,0,51)";
shapeTitle.Characters.Text = "组织结构图";
shapeTitle.Characters.set_CharProps(
(short)VisCellIndices.visCharacterStyle,
(short)VisCellVals.visBold);
shapeTitle.Characters.set_CharProps((short)VisCellIndices.visCharacterSize, 24);
以下代码为导出员工照片
Shape visShapeImage = shape.Import(filepath);
Cell vsoCell = visShapeImage.get_Cells("PinX");
vsoCell.Formula = shape.NameID + "!Width*0.3";
vsoCell = visShapeImage.get_Cells("PinY");
vsoCell.Formula = shape.NameID + "!Height*0.5";
vsoCell = visShapeImage.get_Cells("Width");
vsoCell.Formula = shape.NameID + "!Width*0.5";
vsoCell = visShapeImage.get_Cells("Height");
vsoCell.Formula = shape.NameID + "!Height*0.5";
//设置user-defined cell属性
if (shape.get_CellExists("User.ShowPicture", 0) != 0)
...{
Cell showPicture = shape.get_CellsSRC((short)VisSectionIndices.visSectionUser,
(short)VisRowIndices.visRowUser + 2,
(short)VisCellIndices.visUserValue);
showPicture.Formula = "1";
}
if (shape.get_CellExists("User.HasPicture", 0) != 0)
...{
Cell hasPicture = shape.get_CellsSRC((short)VisSectionIndices.visSectionUser,
(short)VisRowIndices.visRowUser + 10,
(short)VisCellIndices.visUserValue);
hasPicture.Formula = "1";
}
if (shape.get_CellExists("User.PictureID", 0) != 0)
...{
Cell pictureID = shape.get_CellsSRC((short)VisSectionIndices.visSectionUser,
(short)VisRowIndices.visRowUser + 15,
(short)VisCellIndices.visUserValue);
pictureID.Formula = """ + visShapeImage.NameID + """;
}
Cell vsoCell = visShapeImage.get_Cells("PinX");
vsoCell.Formula = shape.NameID + "!Width*0.3";
vsoCell = visShapeImage.get_Cells("PinY");
vsoCell.Formula = shape.NameID + "!Height*0.5";
vsoCell = visShapeImage.get_Cells("Width");
vsoCell.Formula = shape.NameID + "!Width*0.5";
vsoCell = visShapeImage.get_Cells("Height");
vsoCell.Formula = shape.NameID + "!Height*0.5";
//设置user-defined cell属性
if (shape.get_CellExists("User.ShowPicture", 0) != 0)
...{
Cell showPicture = shape.get_CellsSRC((short)VisSectionIndices.visSectionUser,
(short)VisRowIndices.visRowUser + 2,
(short)VisCellIndices.visUserValue);
showPicture.Formula = "1";
}
if (shape.get_CellExists("User.HasPicture", 0) != 0)
...{
Cell hasPicture = shape.get_CellsSRC((short)VisSectionIndices.visSectionUser,
(short)VisRowIndices.visRowUser + 10,
(short)VisCellIndices.visUserValue);
hasPicture.Formula = "1";
}
if (shape.get_CellExists("User.PictureID", 0) != 0)
...{
Cell pictureID = shape.get_CellsSRC((short)VisSectionIndices.visSectionUser,
(short)VisRowIndices.visRowUser + 15,
(short)VisCellIndices.visUserValue);
pictureID.Formula = """ + visShapeImage.NameID + """;
}
欢迎转载,请注明出处~~
- 利用Visio导出组织结构图
- visio画组织结构图
- 使用 Visio 2002 组织结构图解决方案
- 使用 Visio 2002 组织结构图解决方案
- 使用visio 2010绘制组织结构图
- 组织结构图
- 论文 结构图 用 visio
- 树形组织结构图
- 组织结构图,C#
- Extjs制作组织结构图
- orgchar(组织结构图)
- flex 生成组织结构图
- IBM组织结构图相关
- 组织结构图OrganizationChart
- 权限组织结构图
- 中共中央组织结构图
- nginx块组织结构图
- MFC类组织结构图
- 网管测试,看你会多少?
- 理论数学之死亡??
- ASP.NET优化性能的方法
- 让win2000坚决支持大硬盘
- 简版CSS手册
- 利用Visio导出组织结构图
- ASP.NET中Cookie编程的基础知识
- ASP.NET中的错误处理支持
- ASP.Net中利用CSS实现多界面两法
- asp程序错误详细说明例表
- C#实现Web文件上传的两种方法
- 我的大学(续1)
- 存储过程从入门到熟练(c#篇)
- 常见内存泄露及解决方案