EPPlus超链接到另一个工作表中的单元格

我努力将超链接添加到我生成的Excel文件的另一个列表。 我试过这样的:

ws.Cells[1, 1].Formula="HYPERLINK(\"[#]'sheetName'!R4C1\";\"linktext\")" ws.Cells[1, 1].Formula="HYPERLINK(\"#'sheetName'!R4C1\";\"linktext\")" ws.Cells[1, 1].FormulaR1C1="HYPERLINK(\"[#]'sheetName'!R4C1\";\"linktext\")" ws.Cells[1, 1].FormulaR1C1="HYPERLINK(\"#'sheetName'!R4C1\";\"linktext\")" 

在excel 365(完全脱机应用程序)中打开生成的excel文件后,我只是得到消息,文件中有错误,所有使用这个超链接公式的单元格都是空的。

错误消息是:

 we found a problem with some content in FILENAME do you want us to try to recover as much as we can 

如何使其工作?

另外当我把相同的公式手动它工作。

完整的代码:

 using OfficeOpenXml; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ExcelHyperlinkTest { class Program { static void Main(string[] args) { MemoryStream excelStream = new MemoryStream(); ExcelPackage excelFile = new ExcelPackage(excelStream); ExcelWorksheet wsSrc = excelFile.Workbook.Worksheets.Add("src"); ExcelWorksheet wsTgt = excelFile.Workbook.Worksheets.Add("tgt"); wsSrc.Cells[1, 1].Formula = string.Format("HYPERLINK(\"#'{0}'!R{1}C{2}\";\"{3}\")", "tgt", 2, 5, "test"); //FormulaR1C1 excelFile.Save(); excelStream.Position = 0; using (FileStream file = new FileStream("c:\\linkTest.xlsx", FileMode.Create, System.IO.FileAccess.Write)) { byte[] bytes = new byte[excelStream.Length]; excelStream.Read(bytes, 0, (int)excelStream.Length); file.Write(bytes, 0, bytes.Length); excelStream.Close(); } } } } 

这工作

 wsSrc.Cells[1, 6].Value = "test3"; Uri url = new Uri("#'tgt'!B5", UriKind.Relative); wsSrc.Cells[1, 6].Hyperlink = url;