How to create a link inside a cell using EPPlus

后端 未结 6 646
醉酒成梦
醉酒成梦 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:28

    If you are using EPPlus and want to create a link to another sheet within the same document, then this is the proper way to do this:

      var link = "Another Excel Sheet"; //Maximum length is 31 symbols
      using (var excel = new ExcelPackage())
      {
           var ws = excel.Workbook.Worksheets.Add("Test");
           ws.Cells[row, col].Hyperlink =
                    new ExcelHyperLink((char)39 + link + (char)39 + "!A1", 
                    "Name of another excel sheet could be more then 31 symbols");
      }
    

    This is the proper way to create a link to another sheet within Excel document. Having using formula with HYPERLINK function, if a file is downloaded to the client, latest Excel version will raise security warnings.

提交回复
热议问题