我需要在Visio文件中添加一个矩形,并要设置字体和文本颜色,如何做到这一点?
visio.Application app = new visio.Application();
visio.Document doc;
doc = app.Documents.Open(processPath);
visio.Page page = doc.Pages[1];
CreateVisio vis = new CreateVisio();
visio.Shape edit = page.DrawRectangle(3.2d, 6.9d, 4.9d, 7.9d);发布于 2014-03-09 12:05:23
如何创建新的VISIO文档
Microsoft.Office.Interop.Visio.Application application =
new Microsoft.Office.Interop.Visio.Application();
application.Visible = false;
Microsoft.Office.Interop.Visio.Document doc = application.Documents.Add(templatePath);
Microsoft.Office.Interop.Visio.Page page = application.Documents[1].Pages[1];如何获取您正在处理的工作表的宽度和高度
double xPosition = page.PageSheet.get_CellsU("PageWidth").ResultIU;
double yPosition = page.PageSheet.get_CellsU("PageHeight").ResultIU; 我们正在使用有关纸张宽度和高度的信息来知道放在哪里的盒子。我们把根框放在纸的中间,把纸的宽度除以根的数目。另外,我们从yPosition中减去电平数,这样,增加电平数的框将在图表上得到一个较低的位置。
如何创建形状并将其放置在图表(拖放)上
//creating the type of shape in the organizational chart it could be: "Position",
//"Executive", "Manager", "Assistant" and others according
//to what you have in your stencil.
Microsoft.Office.Interop.Visio.Master position = doc.Masters.get_ItemU("Position");
//placing the shape in the xPosition and yPosition coordinates
Microsoft.Office.Interop.Visio.Shape shape = page.Drop(position, xPosition, yPosition); 如何设置形状属性
//set the text
shape.Text = box.Name;
//set hyperlink
if (!String.IsNullOrEmpty(box.HyperLink.Trim()))
{
Hyperlink link = shape.Hyperlinks.Add();
link.Address = box.HyperLink;
}
//set the shape width
shape.get_CellsSRC(
(short)Microsoft.Office.Interop.Visio.VisSectionIndices.
visSectionObject,
(short)Microsoft.Office.Interop.Visio.VisRowIndices.
visRowXFormIn,
(short)Microsoft.Office.Interop.Visio.VisCellIndices.
visXFormWidth).ResultIU = box.Width;
//set the shape height
shape.get_CellsSRC(
(short)Microsoft.Office.Interop.Visio.VisSectionIndices.
visSectionObject,
(short)Microsoft.Office.Interop.Visio.VisRowIndices.
visRowXFormIn,
(short)Microsoft.Office.Interop.Visio.VisCellIndices.
visXFormHeight).ResultIU = box.Height;
//set the shape fore color
shape.Characters.set_CharProps(
(short)Microsoft.Office.Interop.Visio.
VisCellIndices.visCharacterColor,
(short)Utilities.GetVisioColor(box.ForeColor));
//set the shape back color
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowFill,
(short)VisCellIndices.visFillForegnd).FormulaU =
"RGB(" + box.BackColor.R.ToString() + "," + box.BackColor.G.ToString() + ","
+ box.BackColor.B.ToString() + ")"; 连接形状使用connectWithDynamicGlueAndConnector()方法完成。此方法接受两个参数,即父形状和childShape,并将在两个参数之间创建连接器。此方法正是VISIO中找到的方法。
https://stackoverflow.com/questions/21719120
复制相似问题