c# - 将空共享字符串写入单元格 openxml
问题描述
但是,在代码运行后,我正在尝试将共享字符串写入单元格。我发现超链接单元格是空的文本。但是超链接在那里。
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++;
}
我的代码有什么问题吗?
解决方案
推荐阅读
- python-3.x - 在 Python 3.7.3 中将 .txt 文件转换为整数
- javascript - 在我的脚本块上获取无法访问的代码
- python - 我正在尝试在 Spark 中的爆炸列上应用 groupBy
- javascript - 到 Function App 的单页应用程序 Azure 网关基于路径的路由
- javascript - Vue Router 推送有效,但片刻后返回到原始组件
- git - git stash 和 git stash 应用而无需暂时清除工作目录
- firebase-cloud-messaging - Firebase 8.2.0 onBackgroundMessage 显示未定义的重复消息
- linux - 对 proxy.pac 的 IPv6 支持
- javascript - 如何在javascript中为类的所有实例制作getter代理?
- html - html标签而不是 css 背景图像