Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

脚注输出错误 #367

Closed
billjone opened this issue May 30, 2020 · 2 comments
Closed

脚注输出错误 #367

billjone opened this issue May 30, 2020 · 2 comments
Labels
bug file_error file format generation/writing issue
Milestone

Comments

@billjone
Copy link

我的代码
CT_FtnEdnRef m_ftnref = new CT_FtnEdnRef();
m_ftnref.id = m_FtnId;
m_FtnEdnR.Items.Add(m_ftnref);
m_FtnEdnR.ItemsElementName = new List();
m_FtnEdnR.ItemsElementName.Add(RunItemsChoiceType.footnoteReference);
结果输出到 word中的
<w:r>
<w:rPr>
<w:rStyle w:val="a7"/>
</w:rPr>
<w:endnoteReference w:customMarkFollows="off" w:id="3"/>
</w:r>
应该是
<w:r>
<w:rPr>
<w:rStyle w:val="a7"/>
</w:rPr>
<w:footnoteReference w:customMarkFollows="off" w:id="3"/>
</w:r>

我查了下源代码这里是否有错误:
OpenXmlFormats/Wordprocessing/Run.cs
中internal void Write(StreamWriter sw, string nodeName)

           else if (o is CT_FtnEdnRef)
                ((CT_FtnEdnRef)o).Write(sw, "endnoteReference");
            else if (o is CT_FldChar)
                ((CT_FldChar)o).Write(sw, "fldChar");
            else if (o is CT_Empty && this.ItemsElementName[i] == RunItemsChoiceType.footnoteRef)
                sw.Write("<w:footnoteRef/>");
            else if (o is CT_FtnEdnRef)
                ((CT_FtnEdnRef)o).Write(sw, "footnoteReference");
@billjone
Copy link
Author

Footnote.docx

@tonyqus tonyqus added the bug label Jun 1, 2020
@tonyqus tonyqus added this to the NPOI 2.5.2 milestone Jun 1, 2020
@tonyqus tonyqus added the file_error file format generation/writing issue label Jul 4, 2020
@tonyqus
Copy link
Member

tonyqus commented Jul 4, 2020

根据微软官方文档
https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.footnotereference?view=openxml-2.8.1
https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.endnotereference?view=openxml-2.8.1

这两个xml node都是以CT_FtnEdnRef作为Model的,但是应该单独提供相应的继承对象,否则无法区分,会导致解析和生成错误。

将在下一个版本修复

tonyqus added a commit that referenced this issue Jul 4, 2020
@tonyqus tonyqus closed this as completed Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug file_error file format generation/writing issue
Projects
None yet
Development

No branches or pull requests

2 participants