我试图在代码运行后将共享字符串写入单元格。我发现超链接单元格是空的,带有文本。但超链接就在那里。
string[] words = data.Split('!');
string cellReference = string.Format("{0}{1}", columnText, rowIndex);
string uniqueID = "hyperlink" + linkIndex.ToString();
Hyperlink hyperlink1 = new Hyperlink() { Reference = cellReference, Id = uniqueID };
hyperlinks1.Append(hyperlink1);
wsPart.Worksheet.Save();
wsPart.AddHyperlinkRelationship(new System.Uri(attachmentDownloadURL + "?id=" + words[0].ToString(), System.UriKind.Absolute), true, uniqueID);
// add hyperlink text to shared string table
shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new DocumentFormat.OpenXml.Spreadsheet.Text(words[1])));
shareStringPart.SharedStringTable.Save();
cell.CellReference = cellReference;
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
cell.CellValue = new CellValue(linkIndex.ToString());
cell.StyleIndex = styleHyperlink;
linkIndex++;
}
我的代码出了什么问题?