XLSX-如何摆脱默认命名空间前缀 x:?
我正在使用 OOXML SDK 生成 XLSX 电子表格,并且需要删除 x:
命名空间前缀。 我怎样才能实现这个目标?
using (SpreadsheetDocument doc = SpreadsheetDocument.Open("template.xlsx", true)) { //Save the shared string table part if (doc.WorkbookPart.GetPartsOfType().Count() > 0) { SharedStringTablePart shareStringPart =
doc.WorkbookPart.GetPartsOfType().First(); shareStringPart.SharedStringTable.Save(); } //Save the workbook doc.WorkbookPart.Workbook.Save(); }
此处,原始 XLSX 文件来自 Excel 2007,没有前缀,但是在保存操作后会出现前缀。 我怎样才能避免这种情况?
I'm generating XLSX spreadsheet using OOXML SDK, and I need to get rid of x:
namespace prefix. How can I achieve this?
using (SpreadsheetDocument doc = SpreadsheetDocument.Open("template.xlsx", true)) { //Save the shared string table part if (doc.WorkbookPart.GetPartsOfType().Count() > 0) { SharedStringTablePart shareStringPart =
doc.WorkbookPart.GetPartsOfType().First(); shareStringPart.SharedStringTable.Save(); } //Save the workbook doc.WorkbookPart.Workbook.Save(); }
Here, the original XLSX file is coming from Excel 2007 and doesn't have the prefix, however, after the save operation the prefix appears. How can I avoid that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是由 divo 链接的样式表的修改版本,它仅删除单个名称空间并逐字复制其余部分:
Here is a modified version of the stylesheet linked by divo that strips only a single namespace and copies the rest verbatim:
除非我误会了,否则原始文件也具有命名空间 - 仅以默认命名空间的形式。 命名空间首先出了什么问题?
Unless I'm much mistaken the original file is namespaced as well - only in the form of a default namespace. What's wrong with the namespace in the first place?