How to create a link inside a cell using EPPlus

后端 未结 6 637
醉酒成梦
醉酒成梦 2021-02-01 12:40

I am trying to figure out how to write a Hyperlink inside a cell using EPPlus instead of the cell containing the link text. I need it to be recognized as a link and be clickable

6条回答
  •  盖世英雄少女心
    2021-02-01 13:32

    I don't know EPPlus, but in VBA (and I guess C# would use the same principle) you would use the following code:

    Sub Test()
    
        ' place value into cell
        ActiveSheet.[A1] = 13
    
        ' create link and set its range property
        ActiveSheet.Hyperlinks.Add ActiveSheet.[A1], "http://www.google.at"
    
        ' use cell in a calculation
        ActiveSheet.[A2].Formula = "=A1+2"
    
    End Sub
    

    Hyperlinks are objects having a range property, so while your cell value can be changed by overtyping, the link will remain. Edit the cell by a long mouse click

    Hope this helps - good luck MikeD

提交回复
热议问题