我正在努力将添加到另一个列表的超链接添加到我生成的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\")"
Run Code Online (Sandbox Code Playgroud)
在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
Run Code Online (Sandbox Code Playgroud)
如何使它工作?
此外,当我手动将相同的公式放在单元格中时,它的工
完整代码:
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"); …Run Code Online (Sandbox Code Playgroud)