我正在尝试为形状添加超链接,但在执行时会出错。
HRESULT的异常:0x800A03EC
我创建了一个Shape,然后我为超链接分配了一个地址但没有成功。请在C#中运行。代码在没有链接的情况下工作。请参阅以下代码:
InteropExcel.Range r = (InteropExcel.Range)iWS.Cells[rownum, currCol];
InteropExcel.Shape sh = (InteropExcel.Shape)iWS.Shapes.AddShape(MsoAutoShapeType.msoShape4pointStar, Convert.ToSingle(r.Left), Convert.ToSingle(r.Top), 20, 20);
sh.Hyperlink.Address = "c:\\test.txt";
答案 0 :(得分:0)
以下代码显示了如何添加指向excel形状的链接:
InteropExcel.Range rshx = (InteropExcel.Range)iWS.Cells[rownum, currCol];
InteropExcel.Shape shxr = (InteropExcel.Shape)iWS.Shapes
.AddShape(MsoAutoShapeType.msoShapeDiamond,
Convert.ToSingle(rshx.Left), Convert.ToSingle(rshx.Top), 20, 20);
Release(rshx);
shxr.ShapeStyle = MsoShapeStyleIndex.msoShapeStylePreset31;
iWS.Hyperlinks.Add(shxr, linkurl);
Release(shxr);